Skip to content

Commit

Permalink
Test: move try/catch out of large function to avoid deoptimization
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestalmage committed Jan 21, 2016
1 parent f45d624 commit 3762f92
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ Test.prototype.plan = function (count) {
this.planStack = new Error().stack;
};

Test.prototype._run = function () {
var ret;
try {
ret = this.fn(this._publicApi());
} catch (err) {
this._setAssertError(err);
this.exit();
}
return ret;
};

Test.prototype.run = function () {
var self = this;

Expand All @@ -101,14 +112,7 @@ Test.prototype.run = function () {
// wait until all assertions are complete
this._timeout = globals.setTimeout(function () {}, maxTimeout);

var ret;

try {
ret = this.fn(this._publicApi());
} catch (err) {
this._setAssertError(err);
this.exit();
}
var ret = this._run();

var asyncType = 'promises';

Expand Down

0 comments on commit 3762f92

Please sign in to comment.