From 220603ee70d1655cf97a1e9f09fbc5d019c99856 Mon Sep 17 00:00:00 2001 From: wycats Date: Fri, 4 Jun 2010 09:48:03 -0700 Subject: Eliminate the need to check for superclass changes to the callback stack each time through the callbacks --- activesupport/lib/active_support/callbacks.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'activesupport/lib/active_support/callbacks.rb') 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 -- cgit v1.2.3