mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
changes from review
This commit is contained in:
parent
b5a7246523
commit
6770c63302
3 changed files with 16 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue