1
Fork 0
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:
Andy Wingo 2015-12-26 20:16:21 +01:00
parent 8a39162160
commit 620b640a4e

View file

@ -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}."