Skip to content

Commit

Permalink
Small speedup by using >>> in the _encipher() loop which allows us to…
Browse files Browse the repository at this point in the history
… remove two `& 0xFF` instructions. This saves ~30ms on my machine (at cost 12).
  • Loading branch information
Adam B committed Jan 20, 2017
1 parent 422f265 commit 9350b93
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bcrypt/impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ function _encipher(lr, off, P, S) { // This is our bottleneck: 1714/1905 ticks /
l ^= P[0];
for (var i=0, k=BLOWFISH_NUM_ROUNDS-2; i<=k;)
// Feistel substitution on left word
n = S[(l >> 24) & 0xff],
n = S[l >>> 24],
n += S[0x100 | ((l >> 16) & 0xff)],
n ^= S[0x200 | ((l >> 8) & 0xff)],
n += S[0x300 | (l & 0xff)],
r ^= n ^ P[++i],
// Feistel substitution on right word
n = S[(r >> 24) & 0xff],
n = S[r >>> 24],
n += S[0x100 | ((r >> 16) & 0xff)],
n ^= S[0x200 | ((r >> 8) & 0xff)],
n += S[0x300 | (r & 0xff)],
Expand Down

0 comments on commit 9350b93

Please sign in to comment.