Skip to content

Commit b081a5d

Browse files
committed
Improve performance parsing other long packets
1 parent b774c2b commit b081a5d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,9 @@ function decodeString(str) {
286286

287287
// look up attachments if type binary
288288
if (exports.BINARY_EVENT === p.type || exports.BINARY_ACK === p.type) {
289-
var buf = '';
290-
while (str.charAt(++i) !== '-') {
291-
buf += str.charAt(i);
292-
if (i == str.length) break;
293-
}
289+
var start = i + 1;
290+
while (str.charAt(++i) !== '-' && i != str.length) {}
291+
var buf = str.substring(start, i);
294292
if (buf != Number(buf) || str.charAt(i) !== '-') {
295293
throw new Error('Illegal attachments');
296294
}
@@ -299,13 +297,13 @@ function decodeString(str) {
299297

300298
// look up namespace (if any)
301299
if ('/' === str.charAt(i + 1)) {
302-
p.nsp = '';
300+
var start = i + 1;
303301
while (++i) {
304302
var c = str.charAt(i);
305303
if (',' === c) break;
306-
p.nsp += c;
307304
if (i === str.length) break;
308305
}
306+
p.nsp = str.substring(start, i);
309307
} else {
310308
p.nsp = '/';
311309
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy