Skip to content

Commit

Permalink
Merge pull request #18130 from JuliaLang/jb/fix18129
Browse files Browse the repository at this point in the history
fix #18129, optimize some more cases of captured variables
  • Loading branch information
JeffBezanson authored Aug 19, 2016
2 parents 4106d18 + 0137899 commit e3173d3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e3173d3

Please sign in to comment.