adding slightly optimized syntax for range comprehensions that could care less about the index variable. Issue #547

This commit is contained in:
Jeremy Ashkenas
2010-07-27 22:38:38 -04:00
parent 8d544ce80b
commit 051a863ff5
6 changed files with 140 additions and 118 deletions

View File

@@ -1279,7 +1279,7 @@ 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
name = (@name and @name.compile(o)) or scope.freeVariable()
index = @index and @index.compile o
scope.find name if name and not @pattern and not codeInBody
scope.find index if index