提交 d1e5186d 编写于 作者: S Skylot

perf(res): speed up rename of deobfuscated resources

上级 d06ba953
......@@ -167,17 +167,30 @@ public class RootNode {
}
private void updateObfuscatedFiles(ResTableParser parser, List<ResourceFile> resources) {
if (args.isSkipResources()) {
return;
}
long start = System.currentTimeMillis();
int renamedCount = 0;
ResourceStorage resStorage = parser.getResStorage();
ValuesParser valuesParser = new ValuesParser(this, parser.getStrings(), resStorage.getResourcesNames());
for (int i = 0; i < resources.size(); i++) {
ResourceFile resource = resources.get(i);
for (ResourceEntry ri : parser.getResStorage().getResources()) {
if (resource.getOriginalName().equals(valuesParser.getValueString(ri))) {
resource.setAlias(ri);
break;
}
Map<String, ResourceEntry> entryNames = new HashMap<>();
for (ResourceEntry resEntry : resStorage.getResources()) {
String val = valuesParser.getSimpleValueString(resEntry);
if (val != null) {
entryNames.put(val, resEntry);
}
}
for (ResourceFile resource : resources) {
ResourceEntry resEntry = entryNames.get(resource.getOriginalName());
if (resEntry != null) {
resource.setAlias(resEntry);
renamedCount++;
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Renamed obfuscated resources: {}, duration: {}ms", renamedCount, System.currentTimeMillis() - start);
}
}
private void initInnerClasses() {
......
......@@ -47,6 +47,15 @@ public class ValuesParser extends ParserConstants {
}
}
@Nullable
public String getSimpleValueString(ResourceEntry ri) {
RawValue simpleValue = ri.getSimpleValue();
if (simpleValue == null) {
return null;
}
return decodeValue(simpleValue);
}
@Nullable
public String getValueString(ResourceEntry ri) {
RawValue simpleValue = ri.getSimpleValue();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册