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.
This commit is contained in:
@@ -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 ]---------------------------------------------------- */
|
||||
|
||||
|
||||
10
WINGs/tree.c
10
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);
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user