diff options
author | wycats <wycats@gmail.com> | 2010-06-04 09:48:03 -0700 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-06-04 20:11:05 -0700 |
commit | 220603ee70d1655cf97a1e9f09fbc5d019c99856 (patch) | |
tree | 4cc78a6e32bc7a609067ec5aa3d5ef6f63052acc | |
parent | a87b62729715fb286ea613e6e3ec59135a82529d (diff) | |
download | rails-220603ee70d1655cf97a1e9f09fbc5d019c99856.tar.gz rails-220603ee70d1655cf97a1e9f09fbc5d019c99856.tar.bz2 rails-220603ee70d1655cf97a1e9f09fbc5d019c99856.zip |
Eliminate the need to check for superclass changes to the callback stack each time through the callbacks
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 933667c909..ba15043bde 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -390,9 +390,12 @@ module ActiveSupport undef_method "_run_#{symbol}_callbacks" if method_defined?("_run_#{symbol}_callbacks") class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 def _run_#{symbol}_callbacks(key = nil, &blk) - if self.class.send("_update_#{symbol}_superclass_callbacks") - self.class.__define_runner(#{symbol.inspect}) - return _run_#{symbol}_callbacks(key, &blk) + @_initialized_#{symbol}_callbacks ||= begin + if self.class.send("_update_#{symbol}_superclass_callbacks") + self.class.__define_runner(#{symbol.inspect}) + return _run_#{symbol}_callbacks(key, &blk) + end + true end if key |