Skip to content

Commit 9350b93

Browse files
author
Adam B
committed
Small speedup by using >>> in the _encipher() loop which allows us to remove two & 0xFF instructions. This saves ~30ms on my machine (at cost 12).
1 parent 422f265 commit 9350b93

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/bcrypt/impl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,13 @@ function _encipher(lr, off, P, S) { // This is our bottleneck: 1714/1905 ticks /
277277
l ^= P[0];
278278
for (var i=0, k=BLOWFISH_NUM_ROUNDS-2; i<=k;)
279279
// Feistel substitution on left word
280-
n = S[(l >> 24) & 0xff],
280+
n = S[l >>> 24],
281281
n += S[0x100 | ((l >> 16) & 0xff)],
282282
n ^= S[0x200 | ((l >> 8) & 0xff)],
283283
n += S[0x300 | (l & 0xff)],
284284
r ^= n ^ P[++i],
285285
// Feistel substitution on right word
286-
n = S[(r >> 24) & 0xff],
286+
n = S[r >>> 24],
287287
n += S[0x100 | ((r >> 16) & 0xff)],
288288
n ^= S[0x200 | ((r >> 8) & 0xff)],
289289
n += S[0x300 | (r & 0xff)],

0 commit comments

Comments
 (0)