mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-08 19:16:09 +01:00
Basically, on import getResSpec is called multiple times and very often throws an exception. Returning null is much faster and therefore in cases where the caller does not rely on a thrown exception, it may use the new getResSpecUnsafe method.
This commit is contained in:
parent
ef022466be
commit
5d383e4a62
@ -35,12 +35,12 @@ public class ResResSpec {
|
|||||||
this.mId = id;
|
this.mId = id;
|
||||||
String cleanName;
|
String cleanName;
|
||||||
|
|
||||||
try {
|
ResResSpec resResSpec = type.getResSpecUnsafe(name);
|
||||||
ResResSpec resResSpec = type.getResSpec(name);
|
if (resResSpec != null)
|
||||||
cleanName = name + "_APKTOOL_DUPLICATENAME_" + id.toString();
|
cleanName = name + "_APKTOOL_DUPLICATENAME_" + id.toString();
|
||||||
} catch (AndrolibException ex) {
|
else
|
||||||
cleanName = (name.isEmpty() ? ("APKTOOL_DUMMYVAL_" + id.toString()) : name);
|
cleanName = (name.isEmpty() ? ("APKTOOL_DUMMYVAL_" + id.toString()) : name);
|
||||||
}
|
|
||||||
this.mName = cleanName;
|
this.mName = cleanName;
|
||||||
this.mPackage = pkg;
|
this.mPackage = pkg;
|
||||||
this.mType = type;
|
this.mType = type;
|
||||||
|
@ -62,13 +62,17 @@ public final class ResTypeSpec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ResResSpec getResSpec(String name) throws AndrolibException {
|
public ResResSpec getResSpec(String name) throws AndrolibException {
|
||||||
ResResSpec spec = mResSpecs.get(name);
|
ResResSpec spec = getResSpecUnsafe(name);
|
||||||
if (spec == null) {
|
if (spec == null) {
|
||||||
throw new UndefinedResObject(String.format("resource spec: %s/%s", getName(), name));
|
throw new UndefinedResObject(String.format("resource spec: %s/%s", getName(), name));
|
||||||
}
|
}
|
||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResResSpec getResSpecUnsafe(String name) {
|
||||||
|
return mResSpecs.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
public void removeResSpec(ResResSpec spec) throws AndrolibException {
|
public void removeResSpec(ResResSpec spec) throws AndrolibException {
|
||||||
mResSpecs.remove(spec.getName());
|
mResSpecs.remove(spec.getName());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user