mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 13:50:43 +00:00
A little optimization, dottedchain uses ArrayLists
This commit is contained in:
@@ -88,7 +88,19 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
|
||||
@Internal
|
||||
public Map<String, DottedChain> dottedChainCache = new HashMap<>();
|
||||
|
||||
@Internal
|
||||
public Map<Multiname, DottedChain> multinameWithNamespaceCache = new HashMap<>();
|
||||
|
||||
|
||||
public DottedChain getCachedMultinameWithNamespace(Multiname multiName) {
|
||||
return multinameWithNamespaceCache.get(multiName);
|
||||
}
|
||||
|
||||
public void cacheMultinameWithNamespace(Multiname multiName, DottedChain multinameWithNamespace) {
|
||||
multinameWithNamespaceCache.put(multiName, multinameWithNamespace);
|
||||
}
|
||||
|
||||
private void ensureDefault(List<?> list) {
|
||||
if (list.isEmpty()) {
|
||||
list.add(null);
|
||||
@@ -681,6 +693,7 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
ret.constant_namespace_set = new HashArrayList<>(constant_namespace_set);
|
||||
ret.constant_multiname = new HashArrayList<>(constant_multiname);
|
||||
ret.dottedChainCache = new HashMap<>();
|
||||
ret.multinameWithNamespaceCache = new HashMap<>();
|
||||
return ret;
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
throw new RuntimeException();
|
||||
|
||||
+4
-2
@@ -111,6 +111,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -2787,7 +2788,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (m != null) {
|
||||
Namespace ns = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNamespace(ci.abc.constants);
|
||||
String n = m.getName(ci.abc.constants, new ArrayList<>(), true, true /*FIXME!!*/);
|
||||
String nsn = ns == null ? null : ns.getName(ci.abc.constants).toRawString();
|
||||
String nsn = ns == null ? null : ns.getRawName(ci.abc.constants);
|
||||
name_index = constants.getQnameId(
|
||||
n,
|
||||
ns == null ? Namespace.KIND_PACKAGE : ns.kind,
|
||||
@@ -2795,10 +2796,11 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
String pkgRaw = pkg.toRawString();
|
||||
for (int i = 1; i < constants.getMultinameCount(); i++) {
|
||||
Multiname mname = constants.getMultiname(i);
|
||||
if (mname != null && name.equals(mname.getName(constants, null, true, true /*FIXME!!*/))) {
|
||||
if (mname.getNamespace(constants) != null && pkg.equals(mname.getNamespace(constants).getName(constants))) {
|
||||
if (mname.getNamespace(constants) != null && Objects.equals(pkgRaw, mname.getNamespace(constants).getRawName(constants))){
|
||||
name_index = i;
|
||||
break;
|
||||
}
|
||||
|
||||
+17
-17
@@ -536,29 +536,29 @@ public final class AbcIndexing {
|
||||
*/
|
||||
//search all static first
|
||||
if (findStatic && classProperties.containsKey(prop)) {
|
||||
if (!classProperties.containsKey(prop)) {
|
||||
if (parent != null) {
|
||||
TraitIndex ret = parent.findProperty(prop, findStatic, findInstance, findProtected);
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return classProperties.get(prop);
|
||||
TraitIndex ti = classProperties.get(prop);
|
||||
if (ti != null) {
|
||||
return ti;
|
||||
}
|
||||
if (parent != null) {
|
||||
TraitIndex ret = parent.findProperty(prop, findStatic, findInstance, findProtected);
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//now search instance
|
||||
if (findInstance && instanceProperties.containsKey(prop)) {
|
||||
if (!instanceProperties.containsKey(prop)) {
|
||||
if (parent != null) {
|
||||
TraitIndex ret = parent.findProperty(prop, findStatic, findInstance, findProtected);
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
TraitIndex ti = instanceProperties.get(prop);
|
||||
if (ti != null) {
|
||||
return ti;
|
||||
}
|
||||
if (parent != null) {
|
||||
TraitIndex ret = parent.findProperty(prop, findStatic, findInstance, findProtected);
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
return instanceProperties.get(prop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -406,6 +406,10 @@ public class Multiname {
|
||||
}
|
||||
|
||||
public DottedChain getNameWithNamespace(AVM2ConstantPool constants, boolean withSuffix) {
|
||||
DottedChain cached = constants.getCachedMultinameWithNamespace(this);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
Namespace ns = getNamespace(constants);
|
||||
if (ns == null) {
|
||||
NamespaceSet nss = getNamespaceSet(constants);
|
||||
@@ -416,10 +420,14 @@ public class Multiname {
|
||||
}
|
||||
}
|
||||
String name = getName(constants, null, true, false);
|
||||
DottedChain ret;
|
||||
if (ns != null) {
|
||||
return ns.getName(constants).add(name, withSuffix ? getNamespaceSuffix() : "");
|
||||
ret = ns.getName(constants).add(name, withSuffix ? getNamespaceSuffix() : "");
|
||||
} else {
|
||||
ret = new DottedChain(new String[]{name}, new String[]{withSuffix ? getNamespaceSuffix() : ""});
|
||||
}
|
||||
return new DottedChain(new String[]{name}, new String[]{withSuffix ? getNamespaceSuffix() : ""});
|
||||
constants.cacheMultinameWithNamespace(this, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Namespace getNamespace(AVM2ConstantPool constants) {
|
||||
|
||||
Reference in New Issue
Block a user