Skip to content

Commit

Permalink
Revert "when checking for pubsub use a Set and O(1) #member? instead …
Browse files Browse the repository at this point in the history
…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
mloughran committed May 3, 2011
1 parent ae0aeb0 commit f5ed102
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions lib/em-hiredis.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,4 @@
require 'eventmachine' require 'eventmachine'

require 'set'
require 'uri' require 'uri'


module EventMachine module EventMachine
Expand Down
4 changes: 2 additions & 2 deletions lib/em-hiredis/client.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
module EventMachine::Hiredis module EventMachine::Hiredis
class Client class Client
PUBSUB_MESSAGES = Set.new(["message", "pmessage"]) PUBSUB_MESSAGES = %w{message pmessage}.freeze


include EventMachine::Hiredis::EventEmitter include EventMachine::Hiredis::EventEmitter
include EM::Deferrable include EM::Deferrable
Expand Down Expand Up @@ -54,7 +54,7 @@ def connect
deferred = @defs.shift deferred = @defs.shift
deferred.fail(reply) if deferred deferred.fail(reply) if deferred
else else
if reply && PUBSUB_MESSAGES.member?(reply[0]) # reply can be nil if reply && PUBSUB_MESSAGES.include?(reply[0]) # reply can be nil
kind, subscription, d1, d2 = *reply kind, subscription, d1, d2 = *reply


case kind.to_sym case kind.to_sym
Expand Down

0 comments on commit f5ed102

Please sign in to comment.