From 01378992c843d9aa99b2edddd19d387ffe65a673 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 18 Aug 2016 19:25:16 -0400 Subject: [PATCH] fix #18129, optimize some more cases of captured variables --- src/julia-syntax.scm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index f32dd65d9d82c..bca97ff935973 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -2732,25 +2732,27 @@ f(x) = yt(x) (any vinfo:sa vi)) (let* ((leading (filter (lambda (x) (and (pair? x) - (or (and (eq? (car x) 'method) - (length> x 2)) - (eq? (car x) '=)))) + (let ((cx (car x))) + (or (and (eq? cx 'method) (length> x 2)) + (eq? cx '=) + (eq? cx 'call))))) (take-statements-while (lambda (e) (or (atom? e) (memq (car e) '(quote top core line inert local unnecessary meta inbounds boundscheck simdloop implicit-global global globalref - const newvar = null method)))) + const newvar = null method call)))) (lam:body lam)))) - (unused (map cadr leading)) + (unused (map cadr (filter (lambda (x) (memq (car x) '(method =))) + leading))) (def (table))) ;; TODO: reorder leading statements to put assignments where the RHS is ;; `simple-atom?` at the top. (for-each (lambda (e) (set! unused (filter (lambda (v) (not (expr-uses-var e v))) unused)) - (if (memq (cadr e) unused) + (if (and (memq (car e) '(method =)) (memq (cadr e) unused)) (put! def (cadr e) #t))) leading) (for-each (lambda (v)