From c1a677ca4bd48c0bd1341b325087ca10dcd41077 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Sat, 15 Dec 2007 08:55:53 -0500 Subject: [PATCH] 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 :-). --- scheme/ikarus.lists.ss | 8 +++++--- scheme/last-revision | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scheme/ikarus.lists.ss b/scheme/ikarus.lists.ss index 32445de..9962e36 100644 --- a/scheme/ikarus.lists.ss +++ b/scheme/ikarus.lists.ss @@ -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 diff --git a/scheme/last-revision b/scheme/last-revision index 4c127d8..600fe59 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1246 +1248