Skip to content

Commit 81bd729

Browse files
errendirleebyron
authored andcommitted
Fix a bug in the hashString function resulting in all string hashes being 0 (immutable-js#1325)
* Fix the typo in the hashString resulting in all string hashes being 0 * Fix a typo resulting in hashJSObj only returning undefined * Add dist artifacts
1 parent 27b231c commit 81bd729

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

dist/immutable.es.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ function hashString(string) {
906906
// (exclusive) by dropping high bits.
907907
var hashed = 0;
908908
for (var ii = 0; ii < string.length; ii++) {
909-
hashed = (31 * hash + string.charCodeAt(ii)) | 0;
909+
hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
910910
}
911911
return smi(hashed);
912912
}
@@ -921,7 +921,7 @@ function hashJSObj(obj) {
921921
}
922922

923923
hashed = obj[UID_HASH_KEY];
924-
if (hash !== undefined) {
924+
if (hashed !== undefined) {
925925
return hashed;
926926
}
927927

dist/immutable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ function hashString(string) {
912912
// (exclusive) by dropping high bits.
913913
var hashed = 0;
914914
for (var ii = 0; ii < string.length; ii++) {
915-
hashed = (31 * hash + string.charCodeAt(ii)) | 0;
915+
hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
916916
}
917917
return smi(hashed);
918918
}
@@ -927,7 +927,7 @@ function hashJSObj(obj) {
927927
}
928928

929929
hashed = obj[UID_HASH_KEY];
930-
if (hash !== undefined) {
930+
if (hashed !== undefined) {
931931
return hashed;
932932
}
933933

dist/immutable.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Hash.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function hashString(string) {
7777
// (exclusive) by dropping high bits.
7878
let hashed = 0;
7979
for (let ii = 0; ii < string.length; ii++) {
80-
hashed = (31 * hash + string.charCodeAt(ii)) | 0;
80+
hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
8181
}
8282
return smi(hashed);
8383
}
@@ -92,7 +92,7 @@ function hashJSObj(obj) {
9292
}
9393

9494
hashed = obj[UID_HASH_KEY];
95-
if (hash !== undefined) {
95+
if (hashed !== undefined) {
9696
return hashed;
9797
}
9898

0 commit comments

Comments
 (0)