performance fixes

This commit is contained in:
honfika@gmail.com
2015-03-20 14:39:00 +01:00
parent 72b30e17e8
commit d5fb45fd54
8 changed files with 30 additions and 23 deletions

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
}
}

View File

@@ -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);
}
}
}
}