From ae755a3c27c12f2928aa4e32ac99a1736a286e20 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 15 Apr 2021 13:26:57 -0300 Subject: remove objs from fn signatures (cur: 84k/sec) Hoo 8*tch, that's a 8ig improvement! This gets rid of the last spread/destructure, a straggler in parseOneTextNode, and makes the only non-primitive passed to either itself or parseNodes the array of tags to parse, cutting away a 8unch of o8jects which were only getting used the one time. --- upd8.js | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/upd8.js b/upd8.js index 76a4e591..3b495b9a 100755 --- a/upd8.js +++ b/upd8.js @@ -991,11 +991,8 @@ const replacerSpec = { stop_iParse, stop_literal; - const parseOneTextNode = function(input, i, opts) { - const nodes = parseNodes(input, i, { - ...opts, - textOnly: true - }); + const parseOneTextNode = function(input, i, stopAt) { + const nodes = parseNodes(input, i, stopAt, true); return ( nodes.length === 0 ? null : @@ -1006,10 +1003,7 @@ const replacerSpec = { ); }; - const parseNodes = function(input, i, { - stopAt = null, - textOnly = false - } = {}) { + const parseNodes = function(input, i, stopAt, textOnly) { let nodes = []; let escapeNext = false; let string = ''; @@ -1060,9 +1054,7 @@ const replacerSpec = { // Replacer key (or value) - N = parseOneTextNode(input, i, { - stopAt: [tagReplacerValue, tagArgument, tagLabel, tagEnding] - }); + N = parseOneTextNode(input, i, [tagReplacerValue, tagArgument, tagLabel, tagEnding]); if (!stopped) throw endOfInput(i, `reading replacer key`); @@ -1085,9 +1077,7 @@ const replacerSpec = { let replacerSecond; if (stop_literal === tagReplacerValue) { - N = parseNodes(input, i, { - stopAt: [tagArgument, tagLabel, tagEnding] - }); + N = parseNodes(input, i, [tagArgument, tagLabel, tagEnding]); if (!stopped) throw endOfInput(i, `reading replacer value`); if (!N.length) throw makeError(i, `Expected content (replacer value).`); @@ -1111,9 +1101,7 @@ const replacerSpec = { const args = []; while (stop_literal === tagArgument) { - N = parseOneTextNode(input, i, { - stopAt: [tagArgumentValue, tagArgument, tagLabel, tagEnding] - }); + N = parseOneTextNode(input, i, [tagArgumentValue, tagArgument, tagLabel, tagEnding]); if (!stopped) throw endOfInput(i, `reading argument key`); @@ -1126,9 +1114,7 @@ const replacerSpec = { const key = N; i = stop_iParse; - N = parseNodes(input, i, { - stopAt: [tagArgument, tagLabel, tagEnding] - }); + N = parseNodes(input, i, [tagArgument, tagLabel, tagEnding]); if (!stopped) throw endOfInput(i, `reading argument value`); if (!N.length) throw makeError(i, `Expected content (argument value).`); @@ -1142,9 +1128,7 @@ const replacerSpec = { let label; if (stop_literal === tagLabel) { - N = parseOneTextNode(input, i, { - stopAt: [tagEnding] - }); + N = parseOneTextNode(input, i, [tagEnding]); if (!stopped) throw endOfInput(i, `reading label`); if (!N) throw makeError(i, `Expected text (label).`); -- cgit 1.3.0-6-gf8a5