1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-16 00:30:21 +02:00

Intset-next micro-optimizations

* module/language/cps/intset.scm (intset-next): Micro-optimizations.
This commit is contained in:
Andy Wingo 2015-03-31 12:11:22 +02:00
parent 9c8d2b85e8
commit 048d5d340e

View file

@ -236,20 +236,20 @@
(define (visit-branch node shift i) (define (visit-branch node shift i)
(let lp ((i i) (idx (logand (ash i (- shift)) *branch-mask*))) (let lp ((i i) (idx (logand (ash i (- shift)) *branch-mask*)))
(and (< idx *branch-size*) (and (< idx *branch-size*)
(or (visit-node (vector-ref node idx) shift i) (or (let ((node (vector-ref node idx)))
(and node (visit-node node shift i)))
(let ((inc (ash 1 shift))) (let ((inc (ash 1 shift)))
(lp (+ (round-down i shift) inc) (1+ idx))))))) (lp (+ (round-down i shift) inc) (1+ idx)))))))
(define (visit-node node shift i) (define (visit-node node shift i)
(and node
(if (= shift *leaf-bits*) (if (= shift *leaf-bits*)
(visit-leaf node i) (visit-leaf node i)
(visit-branch node (- shift *branch-bits*) i)))) (visit-branch node (- shift *branch-bits*) i)))
(match bs (match bs
(($ <intset> min shift root) (($ <intset> min shift root)
(let ((i (if (and i (< min i)) (let ((i (if (and i (< min i))
(- i min) (- i min)
0))) 0)))
(and (< i (ash 1 shift)) (and root (< i (ash 1 shift))
(let ((i (visit-node root shift i))) (let ((i (visit-node root shift i)))
(and i (+ min i)))))))) (and i (+ min i))))))))