removed useless property accesses from for-of

This commit is contained in:
satyr
2010-09-22 12:55:19 +09:00
parent 07d9e9b71e
commit 540783a6dd
2 changed files with 9 additions and 8 deletions

View File

@@ -1380,12 +1380,13 @@ exports.ForNode = class ForNode extends BaseNode
source = if range then @source.base else @source
codeInBody = @body.contains (n) -> n instanceof CodeNode
scope = o.scope
name = (@name and @name.compile(o)) or scope.freeVariable 'i'
index = @index and @index.compile o
name = @name ?.compile o
index = @index?.compile o
scope.find(name, immediate: yes) if name and not @pattern and (range or not codeInBody)
scope.find(index, immediate: yes) if index
rvar = scope.freeVariable 'result' unless topLevel
ivar = if codeInBody then scope.freeVariable 'i' else if range then name else index or scope.freeVariable 'i'
ivar = (if codeInBody then null else if range then name else index) or
scope.freeVariable 'i'
varPart = ''
guardPart = ''
body = Expressions.wrap([@body])