diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 05742228f..b92fe6446 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -488,14 +488,25 @@ public class GenericTagTreePanel extends GenericTagPanel { private final Object mtroot; private final List listeners = new ArrayList<>(); private final Map nodeCache = new HashMap<>(); + // it is much faster to store the reverse mappings, too + private final Map nodeCacheReverse = new HashMap<>(); private Object getNodeByPath(String path) { + if (nodeCache.containsKey(path)) { return nodeCache.get(path); } return null; } + public String getNodePathName(Object find) { + + if (nodeCacheReverse.containsKey(find)) { + return nodeCacheReverse.get(find); + } + return null; + } + public List getDependentFields(FieldNode fnode) { List ret = new ArrayList<>(); getDependentFields(getNodePathName(fnode), mtroot.getClass().getSimpleName(), mtroot, ret); @@ -522,22 +533,13 @@ public class GenericTagTreePanel extends GenericTagPanel { } } } - for (int i = 0; i < getChildCount(node); i++) { + int count = getChildCount(node); + for (int i = 0; i < count; i++) { FieldNode f = (FieldNode) getChild(node, i); getDependentFields(dependence, currentPath + "." + f.getName(), f, ret); } } - public String getNodePathName(Object find) { - - for (Map.Entry en : nodeCache.entrySet()) { - if (en.getValue().equals(find)) { - return en.getKey(); - } - } - return null; - } - public MyTreeModel(Tag root) { super(new DefaultMutableTreeNode(root)); this.mtroot = root; @@ -555,7 +557,9 @@ public class GenericTagTreePanel extends GenericTagPanel { parentPath += obj.getClass().getSimpleName(); } nodeCache.put(parentPath, obj); - for (int i = 0; i < getChildCount(obj, false); i++) { + nodeCacheReverse.put(obj, parentPath); + int count = getChildCount(obj, false); + for (int i = 0; i < count; i++) { buildCache(getChild(obj, i, false), parentPath); } }