From 16691395e04550df417d6d33046ad46a53298969 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Fri, 26 Oct 2012 18:01:35 -0500 Subject: [PATCH] websock.js: use iteration to receive binary data Instead of using apply with the Uint8Array to push the data onto the receive queue, iterate through the binary data and push it an element at a time. Apparently, doing an apply with a very large binary array can blow the stack. Performance-wise this seems equivalent in Chrome 22 and Firefox 16. --- include/websock.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/websock.js b/include/websock.js index 9d6a306..7d12644 100644 --- a/include/websock.js +++ b/include/websock.js @@ -172,7 +172,10 @@ function decode_message(data) { //Util.Debug(">> decode_message: " + data); if (mode === 'binary') { // push arraybuffer values onto the end - rQ.push.apply(rQ, (new Uint8Array(data))); + var u8 = new Uint8Array(data); + for (var i = 0; i < u8.length; i++) { + rQ.push(u8[i]); + } } else { // base64 decode and concat to the end rQ = rQ.concat(Base64.decode(data, 0));