Skip to content
This repository was archived by the owner on Nov 16, 2024. It is now read-only.

Commit cf975df

Browse files
committed
Improved performance of hBytes increment.
1 parent 77efe95 commit cf975df

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## v0.7.1 / 2017-10-31
4+
### Improved
5+
- performance of hBytes increment.
6+
37
## v0.7.0 / 2017-10-31
48
### Fixed
59
- incorrect result when file size >= 512M.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-sha256",
3-
"version": "0.7.0",
3+
"version": "0.7.1",
44
"main": ["src/sha256.js"],
55
"ignore": [
66
"samples",

build/sha256.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-sha256",
3-
"version": "0.7.0",
3+
"version": "0.7.1",
44
"description": "A simple SHA-256 / SHA-224 hash function for JavaScript supports UTF-8 encoding.",
55
"main": "src/sha256.js",
66
"devDependencies": {

src/sha256.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* [js-sha256]{@link https://github.com/emn178/js-sha256}
33
*
4-
* @version 0.7.0
4+
* @version 0.7.1
55
* @author Chen, Yi-Cyuan [[email protected]]
66
* @copyright Chen, Yi-Cyuan 2014-2017
77
* @license MIT
@@ -208,10 +208,6 @@
208208

209209
this.lastByteIndex = i;
210210
this.bytes += i - this.start;
211-
while (this.bytes > 4294967295) {
212-
++this.hBytes;
213-
this.bytes -= 4294967296;
214-
}
215211
if (i >= 64) {
216212
this.block = blocks[16];
217213
this.start = i - 64;
@@ -221,6 +217,10 @@
221217
this.start = i;
222218
}
223219
}
220+
if (this.bytes > 4294967295) {
221+
this.hBytes += this.bytes / 4294967296 << 0;
222+
this.bytes = this.bytes % 4294967296;
223+
}
224224
return this;
225225
};
226226

0 commit comments

Comments
 (0)