aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/notifications
diff options
context:
space:
mode:
authorDaniel Guettler <daniel.guettler@gmail.com>2010-07-18 07:30:48 -0400
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-19 11:45:50 -0700
commit38f0161aabb302550e1522cb62d19e54d448be9b (patch)
tree5ae750c5337e155ccea2a8edd47430fa15854364 /activesupport/lib/active_support/notifications
parentad4ef4226fd5d47252d30effa41a3ab2f55dbc8d (diff)
downloadrails-38f0161aabb302550e1522cb62d19e54d448be9b.tar.gz
rails-38f0161aabb302550e1522cb62d19e54d448be9b.tar.bz2
rails-38f0161aabb302550e1522cb62d19e54d448be9b.zip
Minor performance improvment in notifications/fanout and active_record/log_subscriber [#5098 state:open]
Diffstat (limited to 'activesupport/lib/active_support/notifications')
-rw-r--r--activesupport/lib/active_support/notifications/fanout.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb
index 526ca26764..64f315cb6a 100644
--- a/activesupport/lib/active_support/notifications/fanout.rb
+++ b/activesupport/lib/active_support/notifications/fanout.rb
@@ -21,11 +21,11 @@ module ActiveSupport
end
def publish(name, *args)
- if listeners = @listeners_for[name]
- listeners.each { |s| s.publish(name, *args) }
- else
- @listeners_for[name] = @subscribers.select { |s| s.publish(name, *args) }
- end
+ listeners_for(name).each { |s| s.publish(name, *args) }
+ end
+
+ def listeners_for(name)
+ @listeners_for[name] ||= @subscribers.select { |s| s.subscribed_to?(name) }
end
# This is a sync queue, so there is not waiting.
@@ -39,9 +39,7 @@ module ActiveSupport
end
def publish(message, *args)
- return unless subscribed_to?(message)
@delegate.call(message, *args)
- true
end
def subscribed_to?(name)