more optimizations for readUInt64lebn
This commit is contained in:
parent
805182c500
commit
08a80d74d5
|
@ -91,8 +91,16 @@ BufferReader.prototype.readUInt64BEBN = function() {
|
|||
};
|
||||
|
||||
BufferReader.prototype.readUInt64LEBN = function() {
|
||||
var data = Array.prototype.slice.call(this.buf, this.pos, this.pos + 8);
|
||||
var bn = new BN(data, 10, 'le');
|
||||
var second = this.buf.readUInt32LE(this.pos);
|
||||
var first = this.buf.readUInt32LE(this.pos + 4);
|
||||
var combined = (first * 0x100000000) + second;
|
||||
var bn;
|
||||
if (combined <= 0x1fffffffffffff) {
|
||||
bn = new BN(combined);
|
||||
} else {
|
||||
var data = Array.prototype.slice.call(this.buf, this.pos, this.pos + 8);
|
||||
bn = new BN(data, 10, 'le');
|
||||
}
|
||||
this.pos = this.pos + 8;
|
||||
return bn;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue