mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
removed useless property accesses from for-of
This commit is contained in:
10
lib/nodes.js
10
lib/nodes.js
@@ -1648,8 +1648,8 @@
|
|||||||
return n instanceof CodeNode;
|
return n instanceof CodeNode;
|
||||||
});
|
});
|
||||||
scope = o.scope;
|
scope = o.scope;
|
||||||
name = (this.name && this.name.compile(o)) || scope.freeVariable('i');
|
name = this.name == null ? undefined : this.name.compile(o);
|
||||||
index = this.index && this.index.compile(o);
|
index = this.index == null ? undefined : this.index.compile(o);
|
||||||
if (name && !this.pattern && (range || !codeInBody)) {
|
if (name && !this.pattern && (range || !codeInBody)) {
|
||||||
scope.find(name, {
|
scope.find(name, {
|
||||||
immediate: true
|
immediate: true
|
||||||
@@ -1665,13 +1665,13 @@
|
|||||||
}
|
}
|
||||||
ivar = (function() {
|
ivar = (function() {
|
||||||
if (codeInBody) {
|
if (codeInBody) {
|
||||||
return scope.freeVariable('i');
|
return null;
|
||||||
} else if (range) {
|
} else if (range) {
|
||||||
return name;
|
return name;
|
||||||
} else {
|
} else {
|
||||||
return index || scope.freeVariable('i');
|
return index;
|
||||||
}
|
}
|
||||||
})();
|
})() || scope.freeVariable('i');
|
||||||
varPart = '';
|
varPart = '';
|
||||||
guardPart = '';
|
guardPart = '';
|
||||||
body = Expressions.wrap([this.body]);
|
body = Expressions.wrap([this.body]);
|
||||||
|
|||||||
@@ -1380,12 +1380,13 @@ exports.ForNode = class ForNode extends BaseNode
|
|||||||
source = if range then @source.base else @source
|
source = if range then @source.base else @source
|
||||||
codeInBody = @body.contains (n) -> n instanceof CodeNode
|
codeInBody = @body.contains (n) -> n instanceof CodeNode
|
||||||
scope = o.scope
|
scope = o.scope
|
||||||
name = (@name and @name.compile(o)) or scope.freeVariable 'i'
|
name = @name ?.compile o
|
||||||
index = @index and @index.compile o
|
index = @index?.compile o
|
||||||
scope.find(name, immediate: yes) if name and not @pattern and (range or not codeInBody)
|
scope.find(name, immediate: yes) if name and not @pattern and (range or not codeInBody)
|
||||||
scope.find(index, immediate: yes) if index
|
scope.find(index, immediate: yes) if index
|
||||||
rvar = scope.freeVariable 'result' unless topLevel
|
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 = ''
|
varPart = ''
|
||||||
guardPart = ''
|
guardPart = ''
|
||||||
body = Expressions.wrap([@body])
|
body = Expressions.wrap([@body])
|
||||||
|
|||||||
Reference in New Issue
Block a user