From c162a83c69a116cdcc2a41ad23a361cb987854f4 Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Wed, 18 Sep 2013 21:25:04 -0700 Subject: [PATCH] More refactoring. --- .../typed-racket/optimizer/unboxed-let.rkt | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt index dacfead7e4..0667af7b47 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt @@ -247,28 +247,21 @@ #:with res ;; add unboxed parameters to the unboxed vars table (let ((to-unbox (syntax->datum #'(fun.unboxed ...)))) - (let loop ((params (syntax->list #'params)) - (i 0) - (real-parts (syntax->list #'(real-params ...))) - (imag-parts (syntax->list #'(imag-params ...))) - (boxed '())) - (cond [(null? params) ; done, create the new clause - ;; real parts of unboxed parameters go first, then all - ;; imag parts, then boxed occurrences of unboxed - ;; parameters will be inserted when optimizing the body - #`((fun) (#%plain-lambda - (real-params ... imag-params ... #,@(reverse boxed)) - body.opt ...))] - [(memq i to-unbox) - ;; we unbox the current param, add to the table - (add-unboxed-var! (car params) (car real-parts) (car imag-parts)) - (loop (cdr params) (add1 i) - (cdr real-parts) (cdr imag-parts) - boxed)] - [else ; that param stays boxed, keep going - (loop (cdr params) (add1 i) - real-parts imag-parts - (cons (car params) boxed))]))))) + (for ([index (in-list to-unbox)] + [real-part (in-syntax #'(real-params ...))] + [imag-part (in-syntax #'(imag-params ...))]) + (add-unboxed-var! (list-ref (syntax->list #'params) index) real-part imag-part)) + (define boxed + (for/list ([param (in-syntax #'params)] + [i (in-naturals)] + #:unless (memq i to-unbox)) + param)) + ;; real parts of unboxed parameters go first, then all + ;; imag parts, then boxed occurrences of unboxed + ;; parameters will be inserted when optimizing the body + #`((fun) (#%plain-lambda + (real-params ... imag-params ... #,@(reverse boxed)) + body.opt ...))))) (define-syntax-class opt-let-clause #:commit