2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-05-15 11:59:37 +03:00

perf(parser): optimize v8 perf deoptimizations (#61)

This commit is contained in:
Nikolay Kostyurin
2020-04-05 15:08:59 +02:00
committed by GitHub
parent e3727dc5f5
commit 97ecba0af6
3 changed files with 93 additions and 14 deletions
+10 -2
View File
@@ -77,7 +77,11 @@ const parse = (input, opts = {}) => {
const getNodes = () => {
const lastNestedNode = nestedNodes.getLast();
return lastNestedNode ? lastNestedNode.content : nodes.toArray();
if (lastNestedNode && Array.isArray(lastNestedNode.content)) {
return lastNestedNode.content;
}
return nodes.toArray();
};
/**
@@ -85,7 +89,11 @@ const parse = (input, opts = {}) => {
* @param {TagNode} tag
*/
const appendNodes = (tag) => {
getNodes().push(tag);
const items = getNodes();
if (Array.isArray(items)) {
items.push(tag);
}
};
/**