aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/callbacks.rb
diff options
context:
space:
mode:
authorMax Shytikov <mshytikov@gmail.com>2012-12-19 16:32:01 +0200
committerMax Shytikov <mshytikov@gmail.com>2012-12-19 16:32:01 +0200
commit5c335420c81f0b9dfa6a22336a21dce1912e5c7f (patch)
treea2ae4cbb2046321fd8baf5e05983902597544681 /activesupport/lib/active_support/callbacks.rb
parentebef8e944a138cd7b161fcd25170e45c2bff092e (diff)
downloadrails-5c335420c81f0b9dfa6a22336a21dce1912e5c7f.tar.gz
rails-5c335420c81f0b9dfa6a22336a21dce1912e5c7f.tar.bz2
rails-5c335420c81f0b9dfa6a22336a21dce1912e5c7f.zip
attempt to fix slow runner name method
Diffstat (limited to 'activesupport/lib/active_support/callbacks.rb')
-rw-r--r--activesupport/lib/active_support/callbacks.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 3a8353857e..e772a297fc 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -1,3 +1,4 @@
+require 'thread_safe'
require 'active_support/concern'
require 'active_support/descendants_tracker'
require 'active_support/core_ext/class/attribute'
@@ -351,10 +352,18 @@ module ActiveSupport
undef_method(name) if method_defined?(name)
end
- def __callback_runner_name(kind)
+ def __callback_runner_name_cache
+ @__callback_runner_name_cache ||= ThreadSafe::Cache.new {|cache, kind| cache[kind] = __generate_callback_runner_name(kind) }
+ end
+
+ def __generate_callback_runner_name(kind)
"_run__#{self.name.hash.abs}__#{kind}__callbacks"
end
+ def __callback_runner_name(kind)
+ __callback_runner_name_cache[kind]
+ end
+
# This is used internally to append, prepend and skip callbacks to the
# CallbackChain.
def __update_callbacks(name, filters = [], block = nil) #:nodoc: