Improved performance of hBytes increment.

This commit is contained in:
Yi-Cyuan Chen
2017-10-31 20:33:20 +08:00
parent 77efe9529c
commit cf975dfa0c
5 changed files with 13 additions and 9 deletions
+5 -5
View File
@@ -1,7 +1,7 @@
/**
* [js-sha256]{@link https://github.com/emn178/js-sha256}
*
* @version 0.7.0
* @version 0.7.1
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2017
* @license MIT
@@ -208,10 +208,6 @@
this.lastByteIndex = i;
this.bytes += i - this.start;
while (this.bytes > 4294967295) {
++this.hBytes;
this.bytes -= 4294967296;
}
if (i >= 64) {
this.block = blocks[16];
this.start = i - 64;
@@ -221,6 +217,10 @@
this.start = i;
}
}
if (this.bytes > 4294967295) {
this.hBytes += this.bytes / 4294967296 << 0;
this.bytes = this.bytes % 4294967296;
}
return this;
};