From 92d95c552c9900669e086af4f6475d01574054e8 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 16 May 2016 02:41:52 -0700 Subject: [PATCH] minor optimizations. --- lib/bcoin/hd.js | 2 +- lib/bcoin/utils.js | 4 ++-- test/chain-test.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/bcoin/hd.js b/lib/bcoin/hd.js index bad0237d..a7817636 100644 --- a/lib/bcoin/hd.js +++ b/lib/bcoin/hd.js @@ -178,8 +178,8 @@ Mnemonic.prototype.createMnemonic = function createMnemonic() { word = 0; for (j = 0; j < 11; j++) { i++; - oct = i / 8 | 0; bit = i % 8; + oct = (i - bit) / 8; word <<= 1; word |= (entropy[oct] >>> (7 - bit)) & 1; } diff --git a/lib/bcoin/utils.js b/lib/bcoin/utils.js index cb47a254..94b57d8c 100644 --- a/lib/bcoin/utils.js +++ b/lib/bcoin/utils.js @@ -1673,8 +1673,8 @@ utils.write64N = function write64N(dst, num, off, be) { assert(num <= utils.MAX_SAFE_INTEGER, 'Number exceeds 2^53-1'); - hi = num / 0x100000000 | 0; lo = num % 0x100000000; + hi = (num - lo) / 0x100000000; if (negative) { hi = ~hi >>> 0; @@ -1793,7 +1793,7 @@ utils.read64N = function read64N(data, off, force53, be) { assert((hi & 0xffe00000) === 0, 'Number exceeds 2^53-1'); - return (hi * 0x100000000) + lo; + return hi * 0x100000000 + lo; }; /** diff --git a/test/chain-test.js b/test/chain-test.js index 01f739c4..efa2c371 100644 --- a/test/chain-test.js +++ b/test/chain-test.js @@ -162,7 +162,7 @@ describe('Chain', function() { }); }); - it('should fail to mine a block with coins on a side chain', function(cb) { + it('should fail to mine a block with coins on an alternate chain', function(cb) { mineBlock(null, cb1, function(err, block) { assert.ifError(err); deleteCoins(block.txs);