aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorBenjamin Quorning <benjamin@quorning.net>2016-05-20 13:38:23 +0200
committerBenjamin Quorning <benjamin@quorning.net>2016-05-20 14:30:08 +0200
commit70d504f626d0a68ce927cd0fddf9af7eec1a3f29 (patch)
tree26862f10530cb3410cae160a1be8e9438b4b14f2 /activerecord
parentd90ae764ec287e477dc5d679233dfc1efbe22828 (diff)
downloadrails-70d504f626d0a68ce927cd0fddf9af7eec1a3f29.tar.gz
rails-70d504f626d0a68ce927cd0fddf9af7eec1a3f29.tar.bz2
rails-70d504f626d0a68ce927cd0fddf9af7eec1a3f29.zip
[ci skip] Update retrieve_connection_pool comment
After PR https://github.com/rails/rails/pull/24844 the documentation for `#retrieve_connection_pool` was out of date. This commit changes: - the reference from `@class_to_pool` to `@owner_to_pool`. - with newer Rubies, `#fetch` isn't significantly slower than `#[]`. Since Rails 5 requires Ruby >= 2.2.2, we can just use `#fetch` here.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb8
1 files changed, 1 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index f3abd01290..f437dafec2 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -896,15 +896,9 @@ module ActiveRecord
end
end
- # Retrieving the connection pool happens a lot so we cache it in @class_to_pool.
+ # Retrieving the connection pool happens a lot, so we cache it in @owner_to_pool.
# This makes retrieving the connection pool O(1) once the process is warm.
# When a connection is established or removed, we invalidate the cache.
- #
- # Ideally we would use #fetch here, as class_to_pool[klass] may sometimes be nil.
- # However, benchmarking (https://gist.github.com/jonleighton/3552829) showed that
- # #fetch is significantly slower than #[]. So in the nil case, no caching will
- # take place, but that's ok since the nil case is not the common one that we wish
- # to optimise for.
def retrieve_connection_pool(spec_name)
owner_to_pool.fetch(spec_name) do
# Check if a connection was previously established in an ancestor process,