Skip to content

Commit

Permalink
Merge pull request #207 from kpdecker/temp-init
Browse files Browse the repository at this point in the history
Do not reset temp vars on Context init.
  • Loading branch information
benjamn committed Jun 29, 2015
2 parents e698f12 + 8d52cda commit 5386919
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions runtime.js
Expand Up @@ -376,7 +376,7 @@
// locations where there is no enclosing try statement.
this.tryEntries = [{ tryLoc: "root" }];
tryLocsList.forEach(pushTryEntry, this);
this.reset();
this.reset(true);
}

runtime.keys = function(object) {
Expand Down Expand Up @@ -449,7 +449,7 @@
Context.prototype = {
constructor: Context,

reset: function() {
reset: function(skipTempReset) {
this.prev = 0;
this.next = 0;
this.sent = undefined;
Expand All @@ -458,12 +458,15 @@

this.tryEntries.forEach(resetTryEntry);

// Pre-initialize at least 20 temporary variables to enable hidden
// class optimizations for simple generators.
for (var tempIndex = 0, tempName;
hasOwn.call(this, tempName = "t" + tempIndex) || tempIndex < 20;
++tempIndex) {
this[tempName] = null;
if (!skipTempReset) {
for (var name in this) {
// Not sure about the optimal order of these conditions:
if (name.charAt(0) === "t" &&
hasOwn.call(this, name) &&
!isNaN(+name.slice(1))) {
this[name] = undefined;
}
}
}
},

Expand Down

0 comments on commit 5386919

Please sign in to comment.