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.
This commit is contained in:
parent
3018cf8c1a
commit
16691395e0
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in New Issue