Ghidra is a software reverse engineering (SRE) framework
changes from review
ghidravore6770c633029e
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/CategoryNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/CategoryNode.javaindex a0ab580dee..70339f27b7 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/CategoryNode.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/CategoryNode.java@@ -168,10 +168,11 @@ public class CategoryNode extends DataTypeTreeNode {}CategoryNode node = new CategoryNode(newCategory, filterState);- List<GTreeNode> allChildrenList = getChildren();- int index = Collections.binarySearch(allChildrenList, node);+ List<GTreeNode> children = getChildren();+ int index = Collections.binarySearch(children, node);if (index >= 0) {- if (node.getName().equals(allChildrenList.get(index).getName())) {+ // if a node with that name exists, then we don't need to add one for the new category+ if (node.getName().equals(children.get(index).getName())) {return;}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeTreeDeleteTask.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeTreeDeleteTask.javaindex f0d3ed1f66..b31a210450 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeTreeDeleteTask.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeTreeDeleteTask.java@@ -31,7 +31,9 @@ import ghidra.util.task.TaskMonitor;public class DataTypeTreeDeleteTask extends Task {- private static final int MAX_NODES = 10;+ // if the total number of nodes is small, we won't need to collapse the tree before deleting+ // the nodes to avoid excess tree events+ private static final int NODE_COUNT_FOR_COLLAPSING_TREE = 100;private Map<ArchiveNode, List<GTreeNode>> nodesByArchive;private DataTypeManagerPlugin plugin;private int nodeCount;@@ -107,7 +109,7 @@ public class DataTypeTreeDeleteTask extends Task {DataTypeArchiveGTree tree = provider.getGTree();GTreeState treeState = tree.getTreeState();try {- if (nodeCount > MAX_NODES) {+ if (nodeCount > NODE_COUNT_FOR_COLLAPSING_TREE) {collapseArchives(tree);}diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeNode.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeNode.javaindex 7844edd2e2..86889f0e37 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeNode.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeNode.java@@ -54,13 +54,15 @@ import util.CollectionUtils;* i.e., new nodes are created), then, by default, the expanded and selected state* feature will be unable to find the correct nodes, since the default <tt>equals()</tt>* method on <tt>GTreeNode</tt> performs a comparison based upon instances. To fix this problem,- * the {@link #equals()} method has been implemented such that nodes are considered equals if they have- * the same name. The {@link #hashCode()} method will return the hash of the name.+ * the {@link #equals()} method has been implemented such that nodes are considered equal if they have+ * the same name. The {@link #hashCode()} method will return the hash of the name. The name+ * attribute was chosen because it should be the most unique and descriptive piece of information+ * available in a generic GTreeNode.* <p><br>* <p>* There are two situations where the {@link #equals(Object)} and {@link #hashCode()} using the* name are insufficient. One is if your tree implementation allows nodes with the same name- * with the same parent. The other possible situation is if your nodes can change their name,+ * with the same parent. The other possible situation is if your nodes can change their name,* which may confuse the tree. If either of these situations apply, just override the* {@link #equals(Object)} and {@link #hashCode()} methods to make them more robust.* <p><br>@@ -190,7 +192,9 @@ public abstract class GTreeNode extends CoreGTreeNode implements Comparable<GTre}/**- * Returns the total number of leaf nodes in the subtree from this node+ * Returns the total number of leaf nodes in the subtree from this node. Note that if any+ * nodes are "lazy" (see {@link GTreeLazyNode}) and not currently loaded, then it will be+ * considered as a leaf and return 1.* @return the total number of leaf nodes in the subtree from this node*/public int getLeafCount() {