Skip to content

Commit 4de7a71

Browse files
committed
- fix simple hash-map
1 parent a656eca commit 4de7a71

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12472,7 +12472,7 @@ reduces them without incurring seq initialization"
1247212472
(-kv-reduce coll
1247312473
(fn [ret k v]
1247412474
(-assoc ret k v))
12475-
(. HashMap -EMPTY))
12475+
(simple-hash-map k v))
1247612476
meta))))
1247712477
(-contains-key? [coll k]
1247812478
(let [k (if-not (keyword? k) k (keyword->obj-map-key k))]
@@ -12628,11 +12628,12 @@ reduces them without incurring seq initialization"
1262812628
(-assoc [coll k v]
1262912629
(let [h (hash k)
1263012630
bucket (unchecked-get hashobj h)]
12631-
(if bucket
12631+
(if (some? bucket)
1263212632
(let [new-bucket (aclone bucket)
12633-
new-hashobj (gobject/clone hashobj)]
12633+
new-hashobj (gobject/clone hashobj)
12634+
i (scan-array-equiv 2 k new-bucket)]
1263412635
(aset new-hashobj h new-bucket)
12635-
(if-let [i (scan-array-equiv 2 k new-bucket)]
12636+
(if (some? i)
1263612637
(do
1263712638
; found key, replace
1263812639
(aset new-bucket (inc i) v)
@@ -12641,7 +12642,8 @@ reduces them without incurring seq initialization"
1264112642
; did not find key, append
1264212643
(.push new-bucket k v)
1264312644
(HashMap. meta (inc count) new-hashobj nil))))
12644-
(let [new-hashobj (gobject/clone hashobj)] ; did not find bucket
12645+
(let [new-hashobj (gobject/clone hashobj)]
12646+
; did not find bucket
1264512647
(unchecked-set new-hashobj h (array k v))
1264612648
(HashMap. meta (inc count) new-hashobj nil)))))
1264712649
(-contains-key? [coll k]
@@ -12656,15 +12658,16 @@ reduces them without incurring seq initialization"
1265612658
(let [h (hash k)
1265712659
bucket (unchecked-get hashobj h)
1265812660
i (when bucket (scan-array-equiv 2 k bucket))]
12659-
(if (not i)
12660-
coll ; key not found, return coll unchanged
12661+
(if (some? i)
1266112662
(let [new-hashobj (gobject/clone hashobj)]
1266212663
(if (> 3 (alength bucket))
1266312664
(js-delete new-hashobj h)
1266412665
(let [new-bucket (aclone bucket)]
1266512666
(.splice new-bucket i 2)
1266612667
(unchecked-set new-hashobj h new-bucket)))
12667-
(HashMap. meta (dec count) new-hashobj nil)))))
12668+
(HashMap. meta (dec count) new-hashobj nil))
12669+
; key not found, return coll unchanged
12670+
coll)))
1266812671

1266912672
IFn
1267012673
(-invoke [coll k]

0 commit comments

Comments
 (0)