Fix exponential behavior in accent production (#834)

src/functions.js was returning two properties referring to the base; since buildHTML runs `JSON.parse(JSON.stringify(tree))` to get an immutable copy, that meant we'd traverse and serialize and parse an exponentially-sized tree.

Test Plan: `\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{A}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}` renders instantly; previously, it reliably timed out with even half that depth.
This commit is contained in:
Sophie Alpert
2017-08-30 04:11:33 -07:00
committed by Kevin Barabash
parent d36ca4a2fa
commit b27d7011d1
3 changed files with 12 additions and 7 deletions

View File

@@ -656,7 +656,6 @@ defineFunction([
label: context.funcName,
isStretchy: isStretchy,
isShifty: isShifty,
value: ordargument(base),
base: base,
};
});
@@ -677,7 +676,6 @@ defineFunction([
label: context.funcName,
isStretchy: false,
isShifty: true,
value: ordargument(base),
base: base,
};
});
@@ -704,12 +702,11 @@ defineFunction([
], {
numArgs: 1,
}, function(context, args) {
const body = args[0];
const base = args[0];
return {
type: "accentUnder",
label: context.funcName,
value: ordargument(body),
body: body,
base: base,
};
});