@@ -12481,9 +12481,15 @@ reduces them without incurring seq initialization"
12481
12481
; hashobj. Each values in hashobj is actually a bucket in order to handle hash
12482
12482
; collisions. A bucket is an array of alternating keys (not their hashes) and
12483
12483
; vals.
12484
- (deftype HashMap [meta count hashobj]
12484
+ (deftype HashMap [meta count hashobj ^:mutable __hash]
12485
+ Object
12486
+ (toString [coll]
12487
+ (pr-str* coll))
12488
+ (equiv [this other]
12489
+ (-equiv this other))
12490
+
12485
12491
IWithMeta
12486
- (-with-meta [coll meta] (HashMap. meta count hashobj))
12492
+ (-with-meta [coll meta] (HashMap. meta count hashobj __hash ))
12487
12493
12488
12494
IMeta
12489
12495
(-meta [coll] meta)
@@ -12503,7 +12509,7 @@ reduces them without incurring seq initialization"
12503
12509
(-equiv [coll other] (equiv-map coll other))
12504
12510
12505
12511
IHash
12506
- (-hash [coll] (hash- coll coll))
12512
+ (-hash [coll] (caching-hash coll hash-unordered- coll __hash ))
12507
12513
12508
12514
ISeqable
12509
12515
(-seq [coll]
@@ -12535,13 +12541,13 @@ reduces them without incurring seq initialization"
12535
12541
(if-let [i (scan-array 2 k new-bucket)]
12536
12542
(do ; found key, replace
12537
12543
(aset new-bucket (inc i) v)
12538
- (HashMap. meta count new-hashobj))
12544
+ (HashMap. meta count new-hashobj nil ))
12539
12545
(do ; did not find key, append
12540
12546
(.push new-bucket k v)
12541
- (HashMap. meta (inc count) new-hashobj))))
12547
+ (HashMap. meta (inc count) new-hashobj nil ))))
12542
12548
(let [new-hashobj (goog.object/clone hashobj)] ; did not find bucket
12543
12549
(aset new-hashobj h (array k v))
12544
- (HashMap. meta (inc count) new-hashobj)))))
12550
+ (HashMap. meta (inc count) new-hashobj nil )))))
12545
12551
(-contains-key? [coll k]
12546
12552
(let [bucket (aget hashobj (hash k))
12547
12553
i (when bucket (scan-array 2 k bucket))]
@@ -12562,7 +12568,7 @@ reduces them without incurring seq initialization"
12562
12568
(let [new-bucket (aclone bucket)]
12563
12569
(.splice new-bucket i 2 )
12564
12570
(aset new-hashobj h new-bucket)))
12565
- (HashMap. meta (dec count) new-hashobj)))))
12571
+ (HashMap. meta (dec count) new-hashobj nil )))))
12566
12572
12567
12573
IFn
12568
12574
(-invoke [coll k]
@@ -12574,7 +12580,7 @@ reduces them without incurring seq initialization"
12574
12580
(-pr-writer [coll writer opts]
12575
12581
(print-map coll pr-writer writer opts)))
12576
12582
12577
- (set! (. HashMap -EMPTY) (HashMap. nil 0 (js-obj )))
12583
+ (set! (. HashMap -EMPTY) (HashMap. nil 0 (js-obj ) empty-unordered-hash ))
12578
12584
12579
12585
(set! (. HashMap -fromArrays) (fn [ks vs]
12580
12586
(let [len (.-length ks)]
@@ -12592,16 +12598,22 @@ reduces them without incurring seq initialization"
12592
12598
(recur (nnext in) (assoc out (first in) (second in)))
12593
12599
out)))
12594
12600
12595
- (deftype Set [meta hash-map]
12601
+ (deftype Set [meta hash-map ^:mutable __hash]
12602
+ Object
12603
+ (toString [coll]
12604
+ (pr-str* coll))
12605
+ (equiv [this other]
12606
+ (-equiv this other))
12607
+
12596
12608
IWithMeta
12597
- (-with-meta [coll meta] (Set. meta hash-map))
12609
+ (-with-meta [coll meta] (Set. meta hash-map __hash ))
12598
12610
12599
12611
IMeta
12600
12612
(-meta [coll] meta)
12601
12613
12602
12614
ICollection
12603
12615
(-conj [coll o]
12604
- (Set. meta (assoc hash-map o nil )))
12616
+ (Set. meta (assoc hash-map o nil ) nil ))
12605
12617
12606
12618
IEmptyableCollection
12607
12619
(-empty [coll] (with-meta (. Set -EMPTY) meta))
@@ -12615,7 +12627,7 @@ reduces them without incurring seq initialization"
12615
12627
other)))
12616
12628
12617
12629
IHash
12618
- (-hash [coll] (hash- coll coll))
12630
+ (-hash [coll] (caching-hash coll hash-unordered- coll __hash ))
12619
12631
12620
12632
ISeqable
12621
12633
(-seq [coll] (keys hash-map))
@@ -12633,7 +12645,7 @@ reduces them without incurring seq initialization"
12633
12645
12634
12646
ISet
12635
12647
(-disjoin [coll v]
12636
- (Set. meta (dissoc hash-map v)))
12648
+ (Set. meta (dissoc hash-map v) nil ))
12637
12649
12638
12650
IFn
12639
12651
(-invoke [coll k]
@@ -12644,4 +12656,4 @@ reduces them without incurring seq initialization"
12644
12656
IPrintWithWriter
12645
12657
(-pr-writer [coll writer opts] (pr-sequential-writer writer pr-writer " #{" " " " }" opts coll)))
12646
12658
12647
- (set! (. Set -EMPTY) (Set. nil (hash-map )))
12659
+ (set! (. Set -EMPTY) (Set. nil (hash-map ) empty-unordered-hash ))
0 commit comments