1012
1012
h
1013
1013
(add-to-string-hash-cache k)))))
1014
1014
1015
+ (defn- safe-value? [n]
1016
+ (and (<= n js/Number.MAX_SAFE_INTEGER)
1017
+ (>= n js/Number.MIN_SAFE_INTEGER)))
1018
+
1015
1019
(defn hash
1016
1020
" Returns the hash code of its argument. Note this is the hash code
1017
1021
consistent with =."
1020
1024
(implements? IHash o)
1021
1025
(bit-xor (-hash o) 0 )
1022
1026
1027
+ (cljs.core/bigint? o)
1028
+ (if (safe-value? o)
1029
+ (hash (js/Number. o))
1030
+ (hash-string (.toString o 32 )))
1031
+
1023
1032
(number? o)
1024
1033
(if ^boolean (js/isFinite o)
1025
1034
(js-mod (Math/floor o) 2147483647 )
1434
1443
1435
1444
(extend-type number
1436
1445
IEquiv
1437
- (-equiv [x o] (identical? x o)))
1446
+ (-equiv [x o]
1447
+ (if (cljs.core/bigint? o)
1448
+ (cljs.core/coercive-= x o)
1449
+ (identical? x o))))
1450
+
1451
+ (extend-type bigint
1452
+ IEquiv
1453
+ (-equiv [x o]
1454
+ (if (cljs.core/js-number? o)
1455
+ (cljs.core/coercive-= x o)
1456
+ (identical? x o))))
1438
1457
1439
1458
(declare with-meta )
1440
1459
@@ -6687,15 +6706,15 @@ reduces them without incurring seq initialization"
6687
6706
6688
6707
; ;; PersistentArrayMap
6689
6708
6690
- (defn- array-index-of-nil? [arr]
6709
+ (defn- array-index-of-nil [arr]
6691
6710
(let [len (alength arr)]
6692
6711
(loop [i 0 ]
6693
6712
(cond
6694
6713
(<= len i) -1
6695
6714
(nil? (aget arr i)) i
6696
6715
:else (recur (+ i 2 ))))))
6697
6716
6698
- (defn- array-index-of-keyword? [arr k]
6717
+ (defn- array-index-of-keyword [arr k]
6699
6718
(let [len (alength arr)
6700
6719
kstr (.-fqn k)]
6701
6720
(loop [i 0 ]
@@ -6705,7 +6724,7 @@ reduces them without incurring seq initialization"
6705
6724
(identical? kstr (.-fqn (aget arr i)))) i
6706
6725
:else (recur (+ i 2 ))))))
6707
6726
6708
- (defn- array-index-of-symbol? [arr k]
6727
+ (defn- array-index-of-symbol [arr k]
6709
6728
(let [len (alength arr)
6710
6729
kstr (.-str k)]
6711
6730
(loop [i 0 ]
@@ -6715,6 +6734,17 @@ reduces them without incurring seq initialization"
6715
6734
(identical? kstr (.-str (aget arr i)))) i
6716
6735
:else (recur (+ i 2 ))))))
6717
6736
6737
+ (defn- equal-number? [x y]
6738
+ (and (number? x) (number? y) (cljs.core/coercive-= x y)))
6739
+
6740
+ (defn- array-index-of-number [arr k]
6741
+ (let [len (alength arr)]
6742
+ (loop [i 0 ]
6743
+ (cond
6744
+ (<= len i) -1
6745
+ (equal-number? k (aget arr i)) i
6746
+ :else (recur (+ i 2 ))))))
6747
+
6718
6748
(defn- array-index-of-identical? [arr k]
6719
6749
(let [len (alength arr)]
6720
6750
(loop [i 0 ]
@@ -6723,7 +6753,7 @@ reduces them without incurring seq initialization"
6723
6753
(identical? k (aget arr i)) i
6724
6754
:else (recur (+ i 2 ))))))
6725
6755
6726
- (defn- array-index-of-equiv? [arr k]
6756
+ (defn- array-index-of-equiv [arr k]
6727
6757
(let [len (alength arr)]
6728
6758
(loop [i 0 ]
6729
6759
(cond
@@ -6733,17 +6763,20 @@ reduces them without incurring seq initialization"
6733
6763
6734
6764
(defn array-index-of [arr k]
6735
6765
(cond
6736
- (keyword? k) (array-index-of-keyword? arr k)
6766
+ (keyword? k) (array-index-of-keyword arr k)
6737
6767
6738
- (or ( string? k) ( number? k) )
6768
+ (string? k)
6739
6769
(array-index-of-identical? arr k)
6740
6770
6741
- (symbol? k) (array-index-of-symbol? arr k)
6771
+ (number? k)
6772
+ (array-index-of-number arr k)
6773
+
6774
+ (symbol? k) (array-index-of-symbol arr k)
6742
6775
6743
6776
(nil? k)
6744
- (array-index-of-nil? arr)
6777
+ (array-index-of-nil arr)
6745
6778
6746
- :else (array-index-of-equiv? arr k)))
6779
+ :else (array-index-of-equiv arr k)))
6747
6780
6748
6781
(defn- array-map-index-of [m k]
6749
6782
(array-index-of (.-arr m) k))
0 commit comments