mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 08:47:35 +02:00
Use explicit if's instead of memv for case
Theory is the generated code can make better use of the processor cached when using explicit if statements than aggregating over a list via memv, since pairs in the list can be located anywhere across memory.
This commit is contained in:
parent
483cdd2758
commit
12d6cbce5a
1 changed files with 10 additions and 2 deletions
|
@ -446,6 +446,12 @@
|
|||
`(,(cadr exprs) ,(rename 'tmp)))
|
||||
(else
|
||||
`(,(rename 'begin) ,@exprs))))
|
||||
(define (agg-cond tmp-sym lis)
|
||||
(if (null? lis)
|
||||
#f
|
||||
`(if (eq? ,tmp-sym (,(rename 'quote) ,(car lis)))
|
||||
#t
|
||||
,(agg-cond tmp-sym (cdr lis)))))
|
||||
(define (clause ls)
|
||||
(cond
|
||||
((null? ls) #f)
|
||||
|
@ -457,8 +463,10 @@
|
|||
,(body (cdar ls))
|
||||
,(clause (cdr ls))))
|
||||
(else
|
||||
`(,(rename 'if) (,(rename 'memv) ,(rename 'tmp)
|
||||
(,(rename 'quote) ,(caar ls)))
|
||||
`(,(rename 'if)
|
||||
,(agg-cond (rename 'tmp) (caar ls))
|
||||
;(,(rename 'memv) ,(rename 'tmp)
|
||||
; (,(rename 'quote) ,(caar ls)))
|
||||
,(body (cdar ls))
|
||||
,(clause (cdr ls))))))
|
||||
`(let ((,(rename 'tmp) ,(cadr expr)))
|
||||
|
|
Loading…
Add table
Reference in a new issue