Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

speed up notification publishing by writing the delegate method

  • Loading branch information...
commit 3d0579fc03fe4adc97c770f148e035ee75745648 1 parent 5548e47
@tenderlove tenderlove authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 activesupport/lib/active_support/notifications.rb
5 activesupport/lib/active_support/notifications.rb
@@ -45,7 +45,10 @@ module Notifications
class << self
attr_writer :notifier
- delegate :publish, :to => :notifier
+ def publish(name, *args)
+ notifier.publish(name, *args)
+ end
def instrument(name, payload = {})
if @instrumenters[name]

4 comments on commit 3d0579f


delegate is slower? Is this true for all version of MRI?


Than defining a method directly? Yes. Delegate requires an extra stack frame, not to mention the extra logic inside the method that delegate generates.


Shame.. I was always a fan of delegate, not any more!


delegate is fine if you have a complex method you're targeting and you don't want to write the delegate method directly. Also it's fine if you don't need the method often. However, in this case, since the notification system is a hotspot, we probably don't want the extra stack frames.

Please sign in to comment.
Something went wrong with that request. Please try again.