1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-28 16:00:22 +02:00

Fix intmap bug for maps with only one element

* module/language/cps/intmap.scm (intmap-ref): Fix bug referencing
  values when there is only one value in the map.
This commit is contained in:
Andy Wingo 2015-03-27 13:40:23 +01:00
parent dfa11aa3f6
commit ef7a71b768

View file

@ -175,16 +175,18 @@
(define (intmap-ref bs i)
(match bs
(($ <intmap> min shift root)
(and (<= min i) (< i (+ min (ash 1 shift)))
(let ((i (- i min)))
(let lp ((node root) (shift shift))
(and node
(if (= shift *branch-bits*)
(vector-ref node (logand i *branch-mask*))
(let* ((shift (- shift *branch-bits*))
(idx (logand (ash i (- shift))
*branch-mask*)))
(lp (vector-ref node idx) shift))))))))))
(if (zero? shift)
(and (= i min) root)
(and (<= min i) (< i (+ min (ash 1 shift)))
(let ((i (- i min)))
(let lp ((node root) (shift shift))
(and node
(if (= shift *branch-bits*)
(vector-ref node (logand i *branch-mask*))
(let* ((shift (- shift *branch-bits*))
(idx (logand (ash i (- shift))
*branch-mask*)))
(lp (vector-ref node idx) shift)))))))))))
(define (intmap-next bs i)
(define (visit-branch node shift i)