From 3d0579fc03fe4adc97c770f148e035ee75745648 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 9 Feb 2011 13:46:47 -0800 Subject: speed up notification publishing by writing the delegate method --- activesupport/lib/active_support/notifications.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/notifications.rb') diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb index fd79188ba4..116f28d360 100644 --- a/activesupport/lib/active_support/notifications.rb +++ b/activesupport/lib/active_support/notifications.rb @@ -45,7 +45,10 @@ module ActiveSupport 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] -- cgit v1.2.3 From 3e02b3702ec640a521214109646bdebb5216bf96 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 9 Feb 2011 14:02:38 -0800 Subject: just use an attr_accessor so we do not pay ||= on every notification call --- activesupport/lib/active_support/notifications.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'activesupport/lib/active_support/notifications.rb') diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb index 116f28d360..30daf9dafc 100644 --- a/activesupport/lib/active_support/notifications.rb +++ b/activesupport/lib/active_support/notifications.rb @@ -44,7 +44,7 @@ module ActiveSupport @instrumenters = Hash.new { |h,k| h[k] = notifier.listening?(k) } class << self - attr_writer :notifier + attr_accessor :notifier def publish(name, *args) notifier.publish(name, *args) @@ -69,13 +69,11 @@ module ActiveSupport @instrumenters.clear end - def notifier - @notifier ||= Fanout.new - end - def instrumenter Thread.current[:"instrumentation_#{notifier.object_id}"] ||= Instrumenter.new(notifier) end end + + self.notifier = Fanout.new end end -- cgit v1.2.3 From 37efb517cb87c0894d8ecaa2066c5be6283f5450 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 9 Feb 2011 14:33:56 -0800 Subject: fanout unsubscribe only accepted one argument, so taking *args here is probably bad --- activesupport/lib/active_support/notifications.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/notifications.rb') diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb index 30daf9dafc..77696eb1db 100644 --- a/activesupport/lib/active_support/notifications.rb +++ b/activesupport/lib/active_support/notifications.rb @@ -64,8 +64,8 @@ module ActiveSupport end end - def unsubscribe(*args) - notifier.unsubscribe(*args) + def unsubscribe(args) + notifier.unsubscribe(args) @instrumenters.clear end -- cgit v1.2.3