« get me outta code hell

remove void parseOneTextNode logic (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:36:58 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-04-15 13:36:58 -0300
commitaaef4b0ca3b1432101d1ca84cc7b4898ddee7789 (patch)
treeaa9e1950ea57209bcaacb5c1d94331cd94db5b74
parent8a0fb4488ccb5dc5c799fe44977ca55edadba3cb (diff)
remove void parseOneTextNode logic (cur: 84k/sec)
If textOnly is passed, parseNodes will only ever return a single text
node, so the other paths were never getting reached. This is only
cleanup, though - no significant performance improvement.
-rwxr-xr-xupd8.js8
1 files changed, 1 insertions, 7 deletions
diff --git a/upd8.js b/upd8.js
index 37b72ae2..eec04d78 100755
--- a/upd8.js
+++ b/upd8.js
@@ -992,13 +992,7 @@ const replacerSpec = {
         stop_literal;
 
     const parseOneTextNode = function(input, i, stopAt) {
-        const nodes = parseNodes(input, i, stopAt, true);
-
-        return (
-            nodes.length === 0 ? null :
-            nodes.length === 1 ? nodes[0] :
-            makeNode(i, 'text', nodes.map(node => node.string).join(' '))
-        );
+        return parseNodes(input, i, stopAt, true)[0];
     };
 
     const parseNodes = function(input, i, stopAt, textOnly) {