Merge pull request #63 from danez/performance-regression
Fix performance regression introduced in 6.8.2
This commit is contained in:
commit
22cf1f8826
@ -732,18 +732,24 @@ export default function (instance) {
|
|||||||
|
|
||||||
instance.extend("parseConditional", function (inner) {
|
instance.extend("parseConditional", function (inner) {
|
||||||
return function (expr, noIn, startPos, startLoc, refNeedsArrowPos) {
|
return function (expr, noIn, startPos, startLoc, refNeedsArrowPos) {
|
||||||
const state = this.state.clone();
|
// only do the expensive clone if there is a question mark
|
||||||
try {
|
// and if we come from inside parens
|
||||||
return inner.call(this, expr, noIn, startPos, startLoc);
|
if (refNeedsArrowPos && this.match(tt.question)) {
|
||||||
} catch (err) {
|
const state = this.state.clone();
|
||||||
if (refNeedsArrowPos && err instanceof SyntaxError) {
|
try {
|
||||||
this.state = state;
|
return inner.call(this, expr, noIn, startPos, startLoc);
|
||||||
refNeedsArrowPos.start = this.state.start;
|
} catch (err) {
|
||||||
return expr;
|
if (err instanceof SyntaxError) {
|
||||||
} else {
|
this.state = state;
|
||||||
throw err;
|
refNeedsArrowPos.start = err.pos || this.state.start;
|
||||||
|
return expr;
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return inner.call(this, expr, noIn, startPos, startLoc);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"throws": "Unexpected token (1:12)"
|
"throws": "Unexpected token (1:13)"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user