mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-29 22:40:34 +02:00
Fix bug in intmap-map
* module/language/cps/utils.scm (intmap-map): Use transient intmap-add! on an empty intmap to build the result instead of intmap-replace! on the argument. Avoids spooky action-at-a-distance mutation of the argument if it happens to be a transient -- although the intmap-fold will correctly traverse a snapshot of the argument and the result will be correct, the argument value would be modified in place, causing strange results to calling code that passes in a transient.
This commit is contained in:
parent
8a39162160
commit
620b640a4e
1 changed files with 2 additions and 2 deletions
|
@ -124,9 +124,9 @@ member, or @code{#f} otherwise."
|
|||
|
||||
(define (intmap-map proc map)
|
||||
(persistent-intmap
|
||||
(intmap-fold (lambda (k v out) (intmap-replace! out k (proc k v)))
|
||||
(intmap-fold (lambda (k v out) (intmap-add! out k (proc k v)))
|
||||
map
|
||||
map)))
|
||||
empty-intmap)))
|
||||
|
||||
(define (intmap-keys map)
|
||||
"Return an intset of the keys in @var{map}."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue