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:
parent
dfa11aa3f6
commit
ef7a71b768
1 changed files with 12 additions and 10 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue