Permalink
Browse files

renderer: getprops should compute object only once

  • Loading branch information...
1 parent cb0d429 commit 9792c5ebd59883cfbaf29a6f44627d33a417552e @indutny committed Sep 27, 2012
Showing with 4 additions and 1 deletion.
  1. +1 −0 lib/spoon/cfg.js
  2. +1 −0 lib/spoon/instruction.js
  3. +2 −1 lib/spoon/renderer.js
View
@@ -1042,6 +1042,7 @@ Cfg.prototype.visitForIn = function visitFor(ast) {
var leftName = left.name;
left = this.visit(left);
right = this.visit(right);
+ right.isExternal = true;
var props = this.add('getprops', [ right ]),
iterator = '__$fi' + props.id;
View
@@ -8,6 +8,7 @@ function Instruction(block, type, args) {
this.id = block.cfg.instructionId++;
this.until = null;
this.test = null;
+ this.isExpression = false;
this.type = type;
this.args = args;
View
@@ -125,7 +125,8 @@ Renderer.prototype.renderInstruction = function renderInstruction(instr) {
// If instruction has external uses - generate it separately and put it's
// result to the variable
- var external = instr.uses.length > 1 ||
+ var external = instr.isExternal ||
+ instr.uses.length > 1 ||
instr.uses.length === 1 &&
instr.uses[0].block !== this.current;

0 comments on commit 9792c5e

Please sign in to comment.