From 64a081f5f47b38653073b969faf7daf51be292b2 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Thu, 21 Apr 2011 15:58:56 -0700 Subject: [PATCH] Refactored Listener#broadcast() might be better off to chekc arguments.length and ignore the check within the loop all together for those cases --- lib/socket.io/listener.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/socket.io/listener.js b/lib/socket.io/listener.js index 983259cb72..01e04bac19 100644 --- a/lib/socket.io/listener.js +++ b/lib/socket.io/listener.js @@ -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; };