From 0a04a4c12e8eec0b8f31b748e90c0346833fcd2f Mon Sep 17 00:00:00 2001 From: Stu Black Date: Wed, 29 Oct 2025 15:13:23 -0400 Subject: [PATCH] Remove depthFirst parameter from WMTreeWalk. WMTreeWalk is only called once, with depthFirst set to true, so we might as well just hard-code that behavior. Also, this parameter appears to have been misnamed (since the search is always DFS) and should properly be named to indicate that it controls if this is a pre- or post-order traversal. --- WINGs/WINGs/WUtil.h | 2 +- WINGs/tree.c | 10 +++------- util/wmmenugen.c | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h index ea1ec114..6ca513a5 100644 --- a/WINGs/WINGs/WUtil.h +++ b/WINGs/WINGs/WUtil.h @@ -643,7 +643,7 @@ void WMSortTree(WMTreeNode *aNode, WMCompareDataProc *comparer); WMTreeNode *WMFindInTreeWithDepthLimit(WMTreeNode * aTree, WMMatchDataProc * match, void *cdata, int limit); /* Walk every node of aNode with `walk' */ -void WMTreeWalk(WMTreeNode *aNode, WMTreeWalkProc * walk, void *data, Bool DepthFirst); +void WMTreeWalk(WMTreeNode *aNode, WMTreeWalkProc * walk, void *data); /* ---[ WINGs/data.c ]---------------------------------------------------- */ diff --git a/WINGs/tree.c b/WINGs/tree.c index b747724a..536e9e92 100644 --- a/WINGs/tree.c +++ b/WINGs/tree.c @@ -158,23 +158,19 @@ WMTreeNode *WMFindInTreeWithDepthLimit(WMTreeNode * aTree, WMMatchDataProc * mat return findNodeInTree(aTree, match, cdata, limit); } -void WMTreeWalk(WMTreeNode * aNode, WMTreeWalkProc * walk, void *data, Bool DepthFirst) +void WMTreeWalk(WMTreeNode * aNode, WMTreeWalkProc * walk, void *data) { int i; WMTreeNode *leaf; wassertr(aNode != NULL); - if (DepthFirst) - (*walk)(aNode, data); + (*walk)(aNode, data); if (aNode->leaves) { for (i = 0; i < WMGetArrayItemCount(aNode->leaves); i++) { leaf = (WMTreeNode *)WMGetFromArray(aNode->leaves, i); - WMTreeWalk(leaf, walk, data, DepthFirst); + WMTreeWalk(leaf, walk, data); } } - - if (!DepthFirst) - (*walk)(aNode, data); } diff --git a/util/wmmenugen.c b/util/wmmenugen.c index f1ad830a..e0c9c9af 100644 --- a/util/wmmenugen.c +++ b/util/wmmenugen.c @@ -178,7 +178,7 @@ int main(int argc, char **argv) } WMSortTree(menu, menuSortFunc); - WMTreeWalk(menu, assemblePLMenuFunc, previousDepth, True); + WMTreeWalk(menu, assemblePLMenuFunc, previousDepth); i = WMGetArrayItemCount(plMenuNodes); if (i > 2) { /* more than one submenu unprocessed is almost certainly an error */