« get me outta code hell

remove objs from fn signatures (cur: 84k/sec) - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-04-15 13:26:57 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-04-15 13:30:06 -0300
commitae755a3c27c12f2928aa4e32ac99a1736a286e20 (patch)
tree812c1f739d441020d0dfdcc9ce134dc4e6058c6a
parent8adc9f202a17578102ccbd3c4989757fdb42cd72 (diff)
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.
-rwxr-xr-xupd8.js32
1 files changed, 8 insertions, 24 deletions
diff --git a/upd8.js b/upd8.js
index 76a4e59..3b495b9 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).`);