8000 Deploy a74700d22fa94b0bc1253fe166ee00487ca001d8 to NPM branch · retyui/immutable-js@7cf8801 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7cf8801

Browse files
author
Travis CI
committed
Deploy a74700d to NPM branch
1 parent 744472a commit 7cf8801

File tree

3 files changed

+126
-110
lines changed

3 files changed

+126
-110
lines changed

dist/immutable.es.js

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -758,50 +758,58 @@ function smi(i32) {
758758
return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
759759
}
760760

761+
var defaultValueOf = Object.prototype.valueOf;
762+
761763
function hash(o) {
762-
if (o === false || o === null || o === undefined) {
763-
return 0;
764-
}
765-
if (typeof o.valueOf === 'function') {
766-
o = o.valueOf();
767-
if (o === false || o === null || o === undefined) {
768-
return 0;
769-
}
770-
}
771-
if (o === true) {
772-
return 1;
773-
}
774-
var type = typeof o;
775-
if (type === 'number') {
776-
if (o !== o || o === Infinity) {
777-
return 0;
778-
}
779-
var h = o | 0;
780-
if (h !== o) {
781-
h ^= o * 0xffffffff;
782-
}
783-
while (o > 0xffffffff) {
784-
o /= 0xffffffff;
785-
h ^= o;
786-
}
787-
return smi(h);
788-
}
789-
if (type === 'string') {
790-
return o.length > STRING_HASH_CACHE_MIN_STRLEN
791-
? cachedHashString(o)
792-
: hashString(o);
764+
switch (typeof o) {
765+
case 'boolean':
766+
// The hash values for built-in constants are a 1 value for each 5-byte
767+
// shift region expect for the first, which encodes the value. This
768+
// reduces the odds of a hash collision for these common values.
769+
return o ? 0x42108421 : 0x42108420;
770+
case 'number':
771+
return hashNumber(o);
772+
case 'string':
773+
return o.length > STRING_HASH_CACHE_MIN_STRLEN
774+
? cachedHashString(o)
775+
: hashString(o);
776+
case 'object':
777+
case 'function':
778+
if (o === null) {
779+
return 0x42108422;
780+
}
781+
if (typeof o.hashCode === 'function') {
782+
// Drop any high bits from accidentally long hash codes.
783+
return smi(o.hashCode(o));
784+
}
785+
if (o.valueOf !== defaultValueOf && typeof o.valueOf === 'function') {
786+
o = o.valueOf(o);
787+
}
788+
return hashJSObj(o);
789+
case 'undefined':
790+
return 0x42108423;
791+
default:
792+
if (typeof o.toString === 'function') {
793+
return hashString(o.toString());
794+
}
795+
throw new Error('Value type ' + typeof o + ' cannot be hashed.');
793796
}
794-
if (typeof o.hashCode === 'function') {
795-
// Drop any high bits from accidentally long hash codes.
796-
return smi(o.hashCode());
797+
}
798+
799+
// Compress arbitrarily large numbers into smi hashes.
800+
function hashNumber(n) {
801+
if (n !== n || n === Infinity) {
802+
return 0;
797803
}
798-
if (type === 'object' || type === 'function') {
799-
return hashJSObj(o);
804+
var hash = n | 0;
805+
if (hash !== n) {
806+
hash ^= n * 0xffffffff;
800807
}
801-
if (typeof o.toString === 'function') {
802-
return hashString(o.toString());
808+
while (n > 0xffffffff) {
809+
n /= 0xffffffff;
810+
hash ^= n;
803811
}
804-
throw new Error('Value type ' + type + ' cannot be hashed.');
812+
return smi(hash);
805813
}
806814

807815
function cachedHashString(string) {

dist/immutable.js

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -764,50 +764,58 @@
764764
return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
765765
}
766766

767+
var defaultValueOf = Object.prototype.valueOf;
768+
767769
function hash(o) {
768-
if (o === false || o === null || o === undefined) {
769-
return 0;
770-
}
771-
if (typeof o.valueOf === 'function') {
772-
o = o.valueOf();
773-
if (o === false || o === null || o === undefined) {
774-
return 0;
775-
}
776-
}
777-
if (o === true) {
778-
return 1;
779-
}
780-
var type = typeof o;
781-
if (type === 'number') {
782-
if (o !== o || o === Infinity) {
783-
return 0;
784-
}
785-
var h = o | 0;
786-
if (h !== o) {
787-
h ^= o * 0xffffffff;
788-
}
789-
while (o > 0xffffffff) {
790-
o /= 0xffffffff;
791-
h ^= o;
792-
}
793-
return smi(h);
794-
}
795-
if (type === 'string') {
796-
return o.length > STRING_HASH_CACHE_MIN_STRLEN
797-
? cachedHashString(o)
798-
: hashString(o);
770+
switch (typeof o) {
771+< 8000 div class="diff-text-inner"> case 'boolean':
772+
// The hash values for built-in constants are a 1 value for each 5-byte
773+
// shift region expect for the first, which encodes the value. This
774+
// reduces the odds of a hash collision for these common values.
775+
return o ? 0x42108421 : 0x42108420;
776+
case 'number':
777+
return hashNumber(o);
778+
case 'string':
779+
return o.length > STRING_HASH_CACHE_MIN_STRLEN
780+
? cachedHashString(o)
781+
: hashString(o);
782+
case 'object':
783+
case 'function':
784+
if (o === null) {
785+
return 0x42108422;
786+
}
787+
if (typeof o.hashCode === 'function') {
788+
// Drop any high bits from accidentally long hash codes.
789+
return smi(o.hashCode(o));
790+
}
791+
if (o.valueOf !== defaultValueOf && typeof o.valueOf === 'function') {
792+
o = o.valueOf(o);
793+
}
794+
return hashJSObj(o);
795+
case 'undefined':
796+
return 0x42108423;
797+
default:
798+
if (typeof o.toString === 'function') {
799+
return hashString(o.toString());
800+
}
801+
throw new Error('Value type ' + typeof o + ' cannot be hashed.');
799802
}
800-
if (typeof o.hashCode === 'function') {
801-
// Drop any high bits from accidentally long hash codes.
802-
return smi(o.hashCode());
803+
}
804+
805+
// Compress arbitrarily large numbers into smi hashes.
806+
function hashNumber(n) {
807+
if (n !== n || n === Infinity) {
808+
return 0;
803809
}
804-
if (type === 'object' || type === 'function') {
805-
return hashJSObj(o);
810+
var hash = n | 0;
811+
if (hash !== n) {
812+
hash ^= n * 0xffffffff;
806813
}
807-
if (typeof o.toString === 'function') {
808-
return hashString(o.toString());
814+
while (n > 0xffffffff) {
815+
n /= 0xffffffff;
816+
hash ^= n;
809817
}
810-
throw new Error('Value type ' + type + ' cannot be hashed.');
818+
return smi(hash);
811819
}
812820

813821
function cachedHashString(string) {

0 commit comments

Comments
 (0)
0