Merge pull request #63 from danez/performance-regression

Fix performance regression introduced in 6.8.2
This commit is contained in:
Sebastian McKenzie 2016-07-03 16:46:44 +01:00 committed by GitHub
commit 22cf1f8826
2 changed files with 17 additions and 11 deletions

View File

@ -732,18 +732,24 @@ export default function (instance) {
instance.extend("parseConditional", function (inner) {
return function (expr, noIn, startPos, startLoc, refNeedsArrowPos) {
// only do the expensive clone if there is a question mark
// and if we come from inside parens
if (refNeedsArrowPos && this.match(tt.question)) {
const state = this.state.clone();
try {
return inner.call(this, expr, noIn, startPos, startLoc);
} catch (err) {
if (refNeedsArrowPos && err instanceof SyntaxError) {
if (err instanceof SyntaxError) {
this.state = state;
refNeedsArrowPos.start = this.state.start;
refNeedsArrowPos.start = err.pos || this.state.start;
return expr;
} else {
throw err;
}
}
}
return inner.call(this, expr, noIn, startPos, startLoc);
};
});

View File

@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:12)"
"throws": "Unexpected token (1:13)"
}