mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-26 20:56:59 +00:00
faster searchTreeItem
This commit is contained in:
@@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.timeline;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
import com.jpexs.decompiler.flash.treeitems.TreeItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -49,6 +51,13 @@ public class AS2Package implements TreeItem {
|
||||
return swf;
|
||||
}
|
||||
|
||||
public List<TreeItem> getAllChildren() {
|
||||
List<TreeItem> result = new ArrayList<>(getChildCount());
|
||||
result.addAll(subPackages.values());
|
||||
result.addAll(scripts.values());
|
||||
return result;
|
||||
}
|
||||
|
||||
public TreeItem getChild(int index) {
|
||||
if (index < subPackages.size()) {
|
||||
for (AS2Package subPackage : subPackages.values()) {
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.timeline;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.treeitems.AS3ClassTreeItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -47,6 +49,13 @@ public class AS3Package extends AS3ClassTreeItem {
|
||||
return swf;
|
||||
}
|
||||
|
||||
public List<AS3ClassTreeItem> getAllChildren() {
|
||||
List<AS3ClassTreeItem> result = new ArrayList<>(getChildCount());
|
||||
result.addAll(subPackages.values());
|
||||
result.addAll(scripts.values());
|
||||
return result;
|
||||
}
|
||||
|
||||
public AS3ClassTreeItem getChild(int index) {
|
||||
if (index < subPackages.size()) {
|
||||
for (AS3Package subPackage : subPackages.values()) {
|
||||
|
||||
@@ -96,7 +96,7 @@ public class Timeline {
|
||||
}
|
||||
}
|
||||
|
||||
public Iterable<Frame> getFrames() {
|
||||
public List<Frame> getFrames() {
|
||||
ensureInitialized();
|
||||
return frames;
|
||||
}
|
||||
|
||||
@@ -1103,7 +1103,7 @@ public class Helper {
|
||||
private static int findRight(int[] imgData, int x, int y, int width) {
|
||||
int result = x;
|
||||
int idx = width * y + x;
|
||||
while ((imgData[idx] >>> 24) > 0 && result < width) {
|
||||
while (result < width && (imgData[idx] >>> 24) > 0) {
|
||||
result++;
|
||||
idx++;
|
||||
}
|
||||
|
||||
@@ -136,6 +136,11 @@ public class ClassesListTreeModel extends AS3ClassTreeItem implements TreeModel
|
||||
return root;
|
||||
}
|
||||
|
||||
public List<AS3ClassTreeItem> getAllChildren(Object parent) {
|
||||
AS3Package pkg = (AS3Package) parent;
|
||||
return pkg.getAllChildren();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AS3ClassTreeItem getChild(Object parent, int index) {
|
||||
AS3Package pkg = (AS3Package) parent;
|
||||
|
||||
@@ -387,9 +387,7 @@ public class TagTreeModel implements TreeModel {
|
||||
|
||||
private List<TreeItem> searchTreeItem(TreeItem obj, TreeItem parent, List<TreeItem> path) {
|
||||
List<TreeItem> ret = null;
|
||||
int cnt = getChildCount(parent);
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
TreeItem n = getChild(parent, i);
|
||||
for (TreeItem n : getAllChildren(parent)) {
|
||||
List<TreeItem> newPath = new ArrayList<>();
|
||||
newPath.addAll(path);
|
||||
newPath.add(n);
|
||||
@@ -455,6 +453,74 @@ public class TagTreeModel implements TreeModel {
|
||||
return swfInfo.folders;
|
||||
}
|
||||
|
||||
public List<? extends TreeItem> getAllChildren(Object parent) {
|
||||
TreeItem parentNode = (TreeItem) parent;
|
||||
if (parentNode == root) {
|
||||
List<TreeItem> result = new ArrayList<>(swfs.size());
|
||||
for (SWFList swfList : swfs) {
|
||||
if (!swfList.isBundle()) {
|
||||
result.add(swfList.get(0));
|
||||
}
|
||||
result.add(swfList);
|
||||
}
|
||||
return result;
|
||||
} else if (parentNode instanceof SWFList) {
|
||||
return ((SWFList) parentNode).swfs;
|
||||
} else if (parentNode instanceof SWF) {
|
||||
return getSwfFolders((SWF) parentNode);
|
||||
} else if (parentNode instanceof FolderItem) {
|
||||
return ((FolderItem) parentNode).subItems;
|
||||
} else if (parentNode instanceof Frame) {
|
||||
return ((Frame) parentNode).innerTags;
|
||||
} else if (parentNode instanceof DefineSpriteTag) {
|
||||
return ((DefineSpriteTag) parentNode).getTimeline().getFrames();
|
||||
} else if (parentNode instanceof DefineBinaryDataTag) {
|
||||
List<SWF> result = new ArrayList<>(1);
|
||||
result.add(((DefineBinaryDataTag) parentNode).innerSwf);
|
||||
return result;
|
||||
} else if (parentNode instanceof AS2Package) {
|
||||
return ((AS2Package) parentNode).getAllChildren();
|
||||
} else if (parentNode instanceof FrameScript) {
|
||||
Frame parentFrame = ((FrameScript) parentNode).getFrame();
|
||||
List<TreeItem> result = new ArrayList<>();
|
||||
result.addAll(parentFrame.actionContainers);
|
||||
result.addAll(parentFrame.actions);
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
TreeItem item = result.get(i);
|
||||
if (item instanceof Tag) {
|
||||
Tag resultTag = (Tag) item;
|
||||
Map<Tag, TagScript> currentTagScriptCache = swfInfos.get(item.getSwf()).tagScriptCache;
|
||||
TagScript tagScript = currentTagScriptCache.get(resultTag);
|
||||
if (tagScript == null) {
|
||||
List<TreeItem> subNodes = new ArrayList<>();
|
||||
if (item instanceof ASMSourceContainer) {
|
||||
for (ASMSource item2 : ((ASMSourceContainer) item).getSubItems()) {
|
||||
subNodes.add(item2);
|
||||
}
|
||||
}
|
||||
tagScript = new TagScript(item.getSwf(), resultTag, subNodes);
|
||||
currentTagScriptCache.put(resultTag, tagScript);
|
||||
}
|
||||
result.set(i, tagScript);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else if (parentNode instanceof TagScript) {
|
||||
return ((TagScript) parentNode).getFrames();
|
||||
} else if (parentNode instanceof ClassesListTreeModel) {
|
||||
ClassesListTreeModel clt = (ClassesListTreeModel) parentNode;
|
||||
return clt.getAllChildren(clt.getRoot());
|
||||
} else if (parentNode instanceof AS3ClassTreeItem) {
|
||||
if (parentNode instanceof AS3Package) {
|
||||
return ((AS3Package) parentNode).getAllChildren();
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeItem getChild(Object parent, int index) {
|
||||
TreeItem parentNode = (TreeItem) parent;
|
||||
|
||||
Reference in New Issue
Block a user