From ccbefff684d63c71e13fbb7507fa41d3400c0c95 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <aaron.patterson@gmail.com>
Date: Mon, 13 May 2013 16:43:27 -0700
Subject: if there is nothing to compile, then do not bother compiling

---
 activesupport/lib/active_support/callbacks.rb | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

(limited to 'activesupport/lib')

diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 6ffe8a750d..8422d4f5f3 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -76,9 +76,14 @@ module ActiveSupport
     #     save
     #   end
     def run_callbacks(kind, &block)
-      runner = send("_#{kind}_callbacks").compile
-      e = Filters::Environment.new(self, false, nil, block)
-      runner.call(e).value
+      cbs = send("_#{kind}_callbacks")
+      if cbs.empty?
+        yield if block_given?
+      else
+        runner = cbs.compile
+        e = Filters::Environment.new(self, false, nil, block)
+        runner.call(e).value
+      end
     end
 
     private
-- 
cgit v1.2.3