Skip to content

Commit

Permalink
perf: slide Buffer window 1 byte at a time;
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Mar 1, 2020
1 parent ffc3244 commit 40c5517
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ export default function () {

var i=0, tmp, out='';
for (; i < 16; i++) {
tmp = BUFFER[IDX++];
tmp = BUFFER[i + IDX];
if (i==6) out += HEX[tmp & 15 | 64];
else if (i==8) out += HEX[tmp & 63 | 128];
else out += HEX[tmp];

if (i & 1 && i > 1 && i < 11) out += '-';
}

IDX++;
return out;
}
3 changes: 2 additions & 1 deletion src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export default function () {

var i=0, tmp, out='';
for (; i < 16; i++) {
tmp = BUFFER[IDX++];
tmp = BUFFER[i + IDX];
if (i==6) out += HEX[tmp & 15 | 64];
else if (i==8) out += HEX[tmp & 63 | 128];
else out += HEX[tmp];

if (i & 1 && i > 1 && i < 11) out += '-';
}

IDX++;
return out;
}

0 comments on commit 40c5517

Please sign in to comment.