From d3311d056ccae94001ae5af083572f2111b61b77 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 15 Apr 2021 16:00:46 -0300 Subject: simple replaceKey/Value syntax (cur: 110k/sec) Not actually a speed-up, 8ut this is easier to read. Learn it from me: with no other 8enefits, prefer what's legi8le, not what's cool! At least in projects where the whole point isn't 8eing cool, anyway. --- upd8.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/upd8.js b/upd8.js index 7ec6b55c..8d22f645 100755 --- a/upd8.js +++ b/upd8.js @@ -1097,13 +1097,19 @@ const replacerSpec = { // Assign first & second to replacer key/value + let replacerKey, + replacerValue; + // Value is an array of nodes, 8ut key is just one (or null). // So if we use replacerFirst as the value, we need to stick // it in an array (on its own). - const [ replacerKey, replacerValue ] = - (replacerSecond - ? [replacerFirst, replacerSecond] - : [null, [replacerFirst]]); + if (replacerSecond) { + replacerKey = replacerFirst; + replacerValue = replacerSecond; + } else { + replacerKey = null; + replacerValue = [replacerFirst]; + } // Arguments -- cgit 1.3.0-6-gf8a5