From 6e1c170ff69c51d86c00a7390b8b7fad9f569c4a Mon Sep 17 00:00:00 2001 From: TreetopFlyer Date: Mon, 24 May 2021 14:26:18 -0400 Subject: [PATCH] simplify terminal branch case in pivot routine --- index.html | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index d652ff9..365c982 100755 --- a/index.html +++ b/index.html @@ -240,29 +240,20 @@ var Pivot = { // collect modifiers effecting leaves let modifiers = []; - let check = N.Step(inLeaf, "ModifyAt", false); - if(check) - { - modifiers = modifiers.concat(check); - } - check = N.Step(inLeaf, "ModifyDown", false); - if(check) - { - modifiers = modifiers.concat(check); - } + let collectModifier = n => modifiers.push(n); + let connectModifiers = n => modifiers.forEach(inModifier => N.Connect(inModifier, n, "ModifyOut", true)); + + N.Walk(collectModifier, inLeaf, "ModifyAt", false); + N.Walk(collectModifier, inLeaf, "ModifyDown", false); if(modifiers.length) { // apply them to the branch inLastBranch.ID.Walk = N.ID.Walk; - modifiers.forEach( inModifier => N.Connect(inModifier, inLastBranch, "ModifyOut") ) + connectModifiers(inLastBranch); // also walk them up and connect, but with "check unique" enabled - N.Walk( inNode=> - { - modifiers.forEach( inModifier => N.Connect(inModifier, inNode, "ModifyOut", true) ) - } - , inLastBranch, "Hierarchy", false); + N.Walk(connectModifiers, inLastBranch, "Hierarchy", false); } // lastly connect the leaf to the branch @@ -275,7 +266,7 @@ var Pivot = { iterator = child => Pivot.Pivot(inRoot, child, inPivotIndicies, inSumIndicies, depth+1); } - N.Step(inParent, "Hierarchy").forEach(iterator); + N.Walk(iterator, inParent, "Hierarchy"); return inParent; }, Create(inPivotIndicies, inSumIndicies)