Skip to content

Commit

Permalink
Refactored Listener#broadcast()
Browse files Browse the repository at this point in the history
might be better off to chekc arguments.length
and ignore the check within the loop all together for those cases
  • Loading branch information
tj committed Apr 21, 2011
1 parent 048eeec commit 64a081f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/socket.io/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ Listener.prototype.broadcast = function(message, except){

for (var i = 0; i < len; ++i){
key = keys[i];
if (!except || ((typeof except == 'number' || typeof except == 'string') && key != except)
|| (Array.isArray(except) && except.indexOf(key) == -1)){
this.clients[key].send(message);
if (except) {
if (Array.isArray(except) && ~except.indexOf(key)) continue;
else if (key == except) continue;
}
this.clients[key].send(message);
}

return this;
};

Expand Down

2 comments on commit 64a081f

@ronkorving
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing an "else" after "continue" is pointless. Just my 2 cents.

@tj
Copy link
Contributor Author

@tj tj commented on 64a081f Apr 26, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, that it is

Please sign in to comment.