Changed implementation of append so that it uses half the cons cells

that it previously used.  Interestingly, this reduced bootstrap time
by 60ms and 2 garbage collections!  And I thought I did not use
append :-).
This commit is contained in:
Abdulaziz Ghuloum 2007-12-15 08:55:53 -05:00
parent 8c0563b2d3
commit c1a677ca4b
2 changed files with 6 additions and 4 deletions

View File

@ -145,18 +145,20 @@
(if (null? h)
ac
(die 'append "not a proper list" ls)))))
(define revcons
(define rev!
(lambda (ls ac)
(cond
[(null? ls) ac]
[else
(revcons ($cdr ls) (cons ($car ls) ac))])))
(let ([ls^ ($cdr ls)])
($set-cdr! ls ac)
(rev! ls^ ls))])))
(define append1
(lambda (ls ls*)
(cond
[(null? ls*) ls]
[else
(revcons (reverse ls ls ls '())
(rev! (reverse ls ls ls '())
(append1 ($car ls*) ($cdr ls*)))])))
(define append
(case-lambda

View File

@ -1 +1 @@
1246
1248