Skip to content

Commit

Permalink
bencode.js: optimise packing so we don't evaluate method on each loop…
Browse files Browse the repository at this point in the history
… iteration

git-svn-id: https://xpra.org/svn/Xpra/trunk@8718 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
joshiggins committed Feb 28, 2015
1 parent fc68264 commit c2b9e77
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/html5/include/bencode.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,18 @@ function bparse(buf) {
function uintToString(uintArray) {
// apply in chunks of 10400 to avoid call stack overflow
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
var s = ""
var s = "";
var skip = 10400;
var slice = uintArray.slice;
for (var i=0, len=uintArray.length; i<len; i+=skip) {
if(!slice) {
if (uintArray.subarray) {
for (var i=0, len=uintArray.length; i<len; i+=skip) {
s += String.fromCharCode.apply(null, uintArray.subarray(i, Math.min(i + skip, len)));
} else {
}
} else {
for (var i=0, len=uintArray.length; i<len; i+=skip) {
s += String.fromCharCode.apply(null, uintArray.slice(i, Math.min(i + skip, len)));
}
}
return s
return s;
}


Expand Down

0 comments on commit c2b9e77

Please sign in to comment.