mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-08 04:59:35 +00:00
performance fixes
This commit is contained in:
@@ -1162,7 +1162,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
public List<ScriptPack> getAS3Packs() {
|
||||
List<ScriptPack> packs = new ArrayList<>();
|
||||
for (ABCContainerTag abcTag : getAbcList()) {
|
||||
packs.addAll(abcTag.getABC().getScriptPacks());
|
||||
packs.addAll(abcTag.getABC().getScriptPacks(null));
|
||||
}
|
||||
return uniqueAS3Packs(packs);
|
||||
}
|
||||
|
||||
@@ -866,10 +866,10 @@ public class ABC {
|
||||
}
|
||||
}
|
||||
|
||||
public List<ScriptPack> getScriptPacks() {
|
||||
public List<ScriptPack> getScriptPacks(String packagePrefix) {
|
||||
List<ScriptPack> ret = new ArrayList<>();
|
||||
for (int i = 0; i < script_info.size(); i++) {
|
||||
ret.addAll(script_info.get(i).getPacks(this, i));
|
||||
ret.addAll(script_info.get(i).getPacks(this, i, packagePrefix));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1045,7 +1045,7 @@ public class ABC {
|
||||
|
||||
public List<ScriptPack> findScriptPacksByPath(String name) {
|
||||
List<ScriptPack> ret = new ArrayList<>();
|
||||
List<ScriptPack> allPacks = getScriptPacks();
|
||||
List<ScriptPack> allPacks = getScriptPacks(null); // todo: honfika: use filter parameter
|
||||
if (name.endsWith(".**") || name.equals("**") || name.endsWith(".++") || name.equals("++")) {
|
||||
name = name.substring(0, name.length() - 2);
|
||||
|
||||
@@ -1076,7 +1076,7 @@ public class ABC {
|
||||
}
|
||||
|
||||
public ScriptPack findScriptPackByPath(String name) {
|
||||
List<ScriptPack> packs = getScriptPacks();
|
||||
List<ScriptPack> packs = getScriptPacks(null);
|
||||
for (ScriptPack en : packs) {
|
||||
if (en.getClassPath().toString().equals(name)) {
|
||||
return en;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ScriptInfo {
|
||||
this.traits = traits;
|
||||
}
|
||||
|
||||
public List<ScriptPack> getPacks(ABC abc, int scriptIndex) {
|
||||
public List<ScriptPack> getPacks(ABC abc, int scriptIndex, String packagePrefix) {
|
||||
List<ScriptPack> ret = new ArrayList<>();
|
||||
|
||||
List<Integer> otherTraits = new ArrayList<>();
|
||||
@@ -66,10 +66,13 @@ public class ScriptInfo {
|
||||
traitIndices.add(j);
|
||||
if (!otherTraits.isEmpty()) {
|
||||
traitIndices.addAll(otherTraits);
|
||||
otherTraits.clear();
|
||||
}
|
||||
|
||||
if (packagePrefix == null || packageName.startsWith(packagePrefix)) {
|
||||
ClassPath cp = new ClassPath(packageName, objectName);
|
||||
ret.add(new ScriptPack(cp, abc, scriptIndex, traitIndices));
|
||||
}
|
||||
otherTraits = new ArrayList<>();
|
||||
ClassPath cp = new ClassPath(packageName, objectName);
|
||||
ret.add(new ScriptPack(cp, abc, scriptIndex, traitIndices));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.types.traits;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
@@ -189,11 +190,11 @@ public abstract class Trait implements Serializable {
|
||||
|
||||
public abstract int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc, String path) throws InterruptedException;
|
||||
|
||||
public String getPath(ABC abc) {
|
||||
public ClassPath getPath(ABC abc) {
|
||||
Multiname name = getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
String packageName = ns.getName(abc.constants, false);
|
||||
String objectName = name.getName(abc.constants, new ArrayList<String>(), false);
|
||||
return packageName + "." + objectName; //assume not null name
|
||||
return new ClassPath(packageName, objectName); //assume not null name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.types.traits;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewFunctionIns;
|
||||
@@ -366,18 +367,12 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
for (ABCContainerTag tag : abc.getAbcTags()) {
|
||||
for (ScriptInfo si : tag.getABC().script_info) {
|
||||
for (Trait t : si.traits.traits) {
|
||||
String spath = t.getPath(tag.getABC());
|
||||
String pkg = "";
|
||||
String name = spath;
|
||||
if (spath.contains(".")) {
|
||||
pkg = spath.substring(0, spath.lastIndexOf('.'));
|
||||
name = spath.substring(spath.lastIndexOf('.') + 1);
|
||||
}
|
||||
ClassPath classPath = t.getPath(tag.getABC());
|
||||
String pkg = classPath.packageStr == null ? "" : classPath.packageStr;
|
||||
if (pkg.equals(packageName)) {
|
||||
namesInThisPackage.add(name);
|
||||
namesInThisPackage.add(classPath.className);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -804,7 +804,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
|
||||
try {
|
||||
String oldSp = null;
|
||||
List<ScriptPack> packs = abc.script_info.get(oldIndex).getPacks(abc, oldIndex);
|
||||
List<ScriptPack> packs = abc.script_info.get(oldIndex).getPacks(abc, oldIndex, null);
|
||||
if (!packs.isEmpty()) {
|
||||
oldSp = packs.get(0).getClassPath().toString();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,8 @@ public class ClassesListTreeModel extends AS3ClassTreeItem implements TreeModel
|
||||
}
|
||||
}
|
||||
|
||||
AS3Package pkg = ensurePackage(item.getClassPath().packageStr);
|
||||
String packageStr = item.getClassPath().packageStr;
|
||||
AS3Package pkg = ensurePackage(packageStr);
|
||||
pkg.addScriptPack(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class DebuggerTools {
|
||||
private static ScriptPack getDebuggerScriptPack(SWF swf) {
|
||||
for (ABCContainerTag ac : swf.getAbcList()) {
|
||||
ABC a = ac.getABC();
|
||||
for (ScriptPack m : a.getScriptPacks()) {
|
||||
for (ScriptPack m : a.getScriptPacks(DEBUGGER_PACKAGE)) {
|
||||
if (isDebuggerClass(m.getClassPath().packageStr, null)) {
|
||||
return m;
|
||||
}
|
||||
@@ -64,11 +64,18 @@ public class DebuggerTools {
|
||||
if (tested == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// fast check, because dynamic regex compile and match is expensive
|
||||
if (!tested.startsWith(DEBUGGER_PACKAGE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cls == null) {
|
||||
cls = "";
|
||||
} else {
|
||||
cls = "\\." + Pattern.quote(cls);
|
||||
}
|
||||
|
||||
return tested.matches(Pattern.quote(DEBUGGER_PACKAGE) + "(\\.pkg[a-f0-9]+)?" + cls);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user