mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
Some hackery to get the Map module to not emit lifetime warnings.
This commit is contained in:
parent
f4c0bb1941
commit
211cfdf65c
@ -170,7 +170,7 @@
|
||||
(let [idx (Int.positive-mod (hash k) @(n-buckets &m))]
|
||||
(update-buckets m &(fn [b]
|
||||
(let [n (Array.nth &b idx)
|
||||
i (Bucket.find n @&k)] ;; Change type signature for Bucket.find to take a ref instead!
|
||||
i (Bucket.find n k)] ;; Change type signature for Bucket.find to take a ref instead!
|
||||
(if (<= 0 i)
|
||||
(let [new-b (Bucket.set-idx @n i &(~f (Bucket.get-idx n i)))]
|
||||
(Array.aset b idx new-b))
|
||||
@ -344,13 +344,15 @@
|
||||
|
||||
(doc put "Put a a key k into the set s.")
|
||||
(defn put [s k]
|
||||
(let [idx (Int.positive-mod (hash k) @(n-buckets &s))]
|
||||
(let [idx (Int.positive-mod (hash k) @(n-buckets &s))
|
||||
;; The lifetime system really doesn't like this function, had to put in a bunch of copying to make it compile:
|
||||
k-copy @k ;; HACK!
|
||||
k-ref &k-copy] ;; HACK!
|
||||
(update-buckets s &(fn [b]
|
||||
(let [n (Array.nth &b idx)
|
||||
kk @&k] ;; TODO: Fix this weird lifetime hackery!
|
||||
(if (SetBucket.contains? n kk)
|
||||
(let [n (Array.nth &b idx)]
|
||||
(if (SetBucket.contains? n k-ref) ;; HACK!
|
||||
b
|
||||
(let [new-b (SetBucket.grow n @kk)]
|
||||
(let [new-b (SetBucket.grow n @&k-copy)] ;; HACK!
|
||||
(Array.aset b idx new-b))))))))
|
||||
|
||||
(doc put! "Put a a key k into the set s, in place.")
|
||||
|
Loading…
Reference in New Issue
Block a user