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 0667af7b47..67acac2ef5 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 @@ -86,9 +86,8 @@ (syntax-parse (cadr p) #:literal-sets (kernel-literals) [(#%plain-lambda params body ...) - (define-values (unboxed boxed) - (for/fold ([unboxed empty] [boxed empty]) - ([param (in-syntax #'params)] + (define unboxed-args + (for/list ([param (in-syntax #'params)] [dom doms] [i (in-naturals)]) (cond @@ -98,14 +97,14 @@ #'(begin body ...))) ;; we can unbox (log-optimization "unboxed var -> table" arity-raising-opt-msg param) - (values (cons i unboxed) boxed)] - [else (values unboxed (cons i boxed))]))) + #t] + [else #f]))) ;; can we unbox anything? - (and (> (length unboxed) 0) + (and (member #t unboxed-args) ;; if so, add to the table of functions with ;; unboxed params, so we can modify its call ;; sites, its body and its header - (add-unboxed-fun! fun-name unboxed boxed))] + (add-unboxed-fun! fun-name unboxed-args))] [_ #f])] [_ #f]))))) rest))) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/unboxed-tables.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/unboxed-tables.rkt index 2cf5d5d745..20e26028dd 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/unboxed-tables.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/unboxed-tables.rkt @@ -37,7 +37,11 @@ ;; params first, then all imaginary parts, then all boxed arguments (define unboxed-funs-table (make-free-id-table)) -(define (add-unboxed-fun! fun-name unboxed boxed) +(define (add-unboxed-fun! fun-name unboxed-args) + (define unboxed + (for/list ([i (in-naturals)] [unboxed? unboxed-args] #:when unboxed?) i)) + (define boxed + (for/list ([i (in-naturals)] [unboxed? unboxed-args] #:unless unboxed?) i)) (dict-set! unboxed-funs-table fun-name (list unboxed boxed))) (define-syntax-class unboxed-fun