diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-17 13:14:38 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-17 13:14:38 -0700 |
commit | 9c80f5b3910ca0573f6e40aaccf3102c260986b6 (patch) | |
tree | 6e341b52b0e3ba5f6ed13b23b1b4633a0a182ee8 /activesupport | |
parent | 631b9564d284d1cbcfabeea272df4b853834fe9d (diff) | |
download | rails-9c80f5b3910ca0573f6e40aaccf3102c260986b6.tar.gz rails-9c80f5b3910ca0573f6e40aaccf3102c260986b6.tar.bz2 rails-9c80f5b3910ca0573f6e40aaccf3102c260986b6.zip |
use === to avoid regular expression creation, and speed up string comparison
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/notifications/fanout.rb | 12 |
1 files changed, 3 insertions, 9 deletions
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 |