no need to save the lookups

This commit is contained in:
Jeremy Ashkenas
2010-03-10 22:32:00 -05:00
parent 0379431812
commit 3c597dde72
2 changed files with 9 additions and 5 deletions

View File

@@ -1307,15 +1307,19 @@
// comprehensions. Some of the generated code can be shared in common, and // comprehensions. Some of the generated code can be shared in common, and
// some cannot. // some cannot.
ForNode.prototype.compile_node = function compile_node(o) { ForNode.prototype.compile_node = function compile_node(o) {
var body, body_dent, close, for_part, index, index_found, index_var, ivar, lvar, name, name_found, range, return_result, rvar, scope, set_result, source, source_part, step_part, svar, top_level, var_part, vars; var body, body_dent, close, for_part, index, index_var, ivar, lvar, name, range, return_result, rvar, scope, set_result, source, source_part, step_part, svar, top_level, var_part, vars;
top_level = del(o, 'top') && !o.returns; top_level = del(o, 'top') && !o.returns;
range = this.source instanceof ValueNode && this.source.base instanceof RangeNode && !this.source.properties.length; range = this.source instanceof ValueNode && this.source.base instanceof RangeNode && !this.source.properties.length;
source = range ? this.source.base : this.source; source = range ? this.source.base : this.source;
scope = o.scope; scope = o.scope;
name = this.name && this.name.compile(o); name = this.name && this.name.compile(o);
index = this.index && this.index.compile(o); index = this.index && this.index.compile(o);
name_found = name && scope.find(name); if (name) {
index_found = index && scope.find(index); scope.find(name);
}
if (index) {
scope.find(index);
}
body_dent = this.idt(1); body_dent = this.idt(1);
if (!(top_level)) { if (!(top_level)) {
rvar = scope.free_variable(); rvar = scope.free_variable();

View File

@@ -1000,8 +1000,8 @@ exports.ForNode: class ForNode extends BaseNode
scope: o.scope scope: o.scope
name: @name and @name.compile o name: @name and @name.compile o
index: @index and @index.compile o index: @index and @index.compile o
name_found: name and scope.find name scope.find name if name
index_found: index and scope.find index scope.find index if index
body_dent: @idt(1) body_dent: @idt(1)
rvar: scope.free_variable() unless top_level rvar: scope.free_variable() unless top_level
svar: scope.free_variable() svar: scope.free_variable()