@@ -6560,15 +6560,6 @@ reduces them without incurring seq initialization"
6560
6560
(= (get y (first xkv) never-equiv) (second xkv)))
6561
6561
x))))))
6562
6562
6563
-
6564
- (defn- scan-array [incr k array]
6565
- (let [len (alength array)]
6566
- (loop [i 0 ]
6567
- (when (< i len)
6568
- (if (identical? k (aget array i))
6569
- i
6570
- (recur (+ i incr)))))))
6571
-
6572
6563
; ; Record Iterator
6573
6564
(deftype RecordIter [^:mutable i record base-count fields ext-map-iter]
6574
6565
Object
@@ -12414,6 +12405,14 @@ reduces them without incurring seq initialization"
12414
12405
(keyword (.substring k 2 (. k -length)))
12415
12406
k))
12416
12407
12408
+ (defn- scan-array [incr k array]
12409
+ (let [len (alength array)]
12410
+ (loop [i 0 ]
12411
+ (when (< i len)
12412
+ (if (identical? k (aget array i))
12413
+ i
12414
+ (recur (+ i incr)))))))
12415
+
12417
12416
(deftype ObjMap [meta keys strobj ^:mutable __hash]
12418
12417
IWithMeta
12419
12418
(-with-meta [coll meta] (ObjMap. meta keys strobj __hash))
@@ -12560,6 +12559,14 @@ reduces them without incurring seq initialization"
12560
12559
(recur (nnext kvs)))
12561
12560
(.fromObject ObjMap ks obj)))))
12562
12561
12562
+ (defn- scan-array-equiv [incr k array]
12563
+ (let [len (alength array)]
12564
+ (loop [i 0 ]
12565
+ (when (< i len)
12566
+ (if (= k (aget array i))
12567
+ i
12568
+ (recur (+ i incr)))))))
12569
+
12563
12570
; The keys field is an array of all keys of this map, in no particular
12564
12571
; order. Each key is hashed and the result used as a property name of
12565
12572
; hashobj. Each values in hashobj is actually a bucket in order to handle hash
@@ -12611,42 +12618,44 @@ reduces them without incurring seq initialization"
12611
12618
ILookup
12612
12619
(-lookup [coll k] (-lookup coll k nil ))
12613
12620
(-lookup [coll k not-found]
12614
- (let [bucket (aget hashobj (hash k))
12615
- i (when bucket (scan-array 2 k bucket))]
12616
- (if i
12621
+ (let [bucket (unchecked-get hashobj (hash k))
12622
+ i (when bucket (scan-array-equiv 2 k bucket))]
12623
+ (if ( some? i)
12617
12624
(aget bucket (inc i))
12618
12625
not-found)))
12619
12626
12620
12627
IAssociative
12621
12628
(-assoc [coll k v]
12622
12629
(let [h (hash k)
12623
- bucket (aget hashobj h)]
12630
+ bucket (unchecked-get hashobj h)]
12624
12631
(if bucket
12625
12632
(let [new-bucket (aclone bucket)
12626
12633
new-hashobj (gobject/clone hashobj)]
12627
12634
(aset new-hashobj h new-bucket)
12628
- (if-let [i (scan-array 2 k new-bucket)]
12629
- (do ; found key, replace
12635
+ (if-let [i (scan-array-equiv 2 k new-bucket)]
12636
+ (do
12637
+ ; found key, replace
12630
12638
(aset new-bucket (inc i) v)
12631
12639
(HashMap. meta count new-hashobj nil ))
12632
- (do ; did not find key, append
12640
+ (do
12641
+ ; did not find key, append
12633
12642
(.push new-bucket k v)
12634
12643
(HashMap. meta (inc count) new-hashobj nil ))))
12635
12644
(let [new-hashobj (gobject/clone hashobj)] ; did not find bucket
12636
12645
(unchecked-set new-hashobj h (array k v))
12637
12646
(HashMap. meta (inc count) new-hashobj nil )))))
12638
12647
(-contains-key? [coll k]
12639
12648
(let [bucket (unchecked-get hashobj (hash k))
12640
- i (when bucket (scan-array 2 k bucket))]
12641
- (if i
12649
+ i (when bucket (scan-array-equiv 2 k bucket))]
12650
+ (if ( some? i)
12642
12651
true
12643
12652
false )))
12644
12653
12645
12654
IMap
12646
12655
(-dissoc [coll k]
12647
12656
(let [h (hash k)
12648
12657
bucket (unchecked-get hashobj h)
12649
- i (when bucket (scan-array 2 k bucket))]
12658
+ i (when bucket (scan-array-equiv 2 k bucket))]
12650
12659
(if (not i)
12651
12660
coll ; key not found, return coll unchanged
12652
12661
(let [new-hashobj (gobject/clone hashobj)]
0 commit comments