Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Revert "when checking for pubsub use a Set and O(1) #member? instead …

…of O(n) #include? on an Array"

It such a micro-optimization that I don't think it justifies the loading of 'set' (https://gist.github.com/935775)

This reverts commit c1d45f3.
  • Loading branch information...
commit f5ed102f423a14ef71ed9b86b456f7915c0705e9 1 parent ae0aeb0
Martyn Loughran authored May 03, 2011
2  lib/em-hiredis.rb
... ...
@@ -1,6 +1,4 @@
1 1
 require 'eventmachine'
2  
-
3  
-require 'set'
4 2
 require 'uri'
5 3
 
6 4
 module EventMachine
4  lib/em-hiredis/client.rb
... ...
@@ -1,6 +1,6 @@
1 1
 module EventMachine::Hiredis
2 2
   class Client
3  
-    PUBSUB_MESSAGES = Set.new(["message", "pmessage"])
  3
+    PUBSUB_MESSAGES = %w{message pmessage}.freeze
4 4
 
5 5
     include EventMachine::Hiredis::EventEmitter
6 6
     include EM::Deferrable
@@ -54,7 +54,7 @@ def connect
54 54
           deferred = @defs.shift
55 55
           deferred.fail(reply) if deferred
56 56
         else
57  
-          if reply && PUBSUB_MESSAGES.member?(reply[0]) # reply can be nil
  57
+          if reply && PUBSUB_MESSAGES.include?(reply[0]) # reply can be nil
58 58
             kind, subscription, d1, d2 = *reply
59 59
 
60 60
             case kind.to_sym

0 notes on commit f5ed102

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