From 9c80f5b3910ca0573f6e40aaccf3102c260986b6 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sat, 17 Jul 2010 13:14:38 -0700 Subject: use === to avoid regular expression creation, and speed up string comparison --- activesupport/lib/active_support/notifications/fanout.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'activesupport/lib/active_support/notifications/fanout.rb') diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb index 300ec842a9..b27713e4ad 100644 --- a/activesupport/lib/active_support/notifications/fanout.rb +++ b/activesupport/lib/active_support/notifications/fanout.rb @@ -39,13 +39,7 @@ module ActiveSupport class Binding #:nodoc: def initialize(queue, pattern) @queue = queue - @pattern = - case pattern - when Regexp, NilClass - pattern - else - /^#{Regexp.escape(pattern.to_s)}$/ - end + @pattern = pattern end def subscribe(&block) @@ -70,13 +64,13 @@ module ActiveSupport end def subscribed_to?(name) - !@pattern || @pattern =~ name.to_s + !@pattern || @pattern === name.to_s end def matches?(subscriber_or_name) case subscriber_or_name when String - @pattern && @pattern =~ subscriber_or_name + @pattern && @pattern === subscriber_or_name when self true end -- cgit v1.2.3