Reduce memory allocations in dexlayout's CodeFixups.
Using heaptrack for the services.odex compilation of
aosp_taimen-userdebug:
- before: calls to allocation functions: 5032880
- after: calls to allocation functions: 4645378
Test: Rely on TreeHugger
Bug: 70331349
Change-Id: I477d5a84e0bf22994ce3de9fe56525de0b498801
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index d904a52..1016fca 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -1656,11 +1656,11 @@
continue;
}
// Add const-strings.
- for (dex_ir::StringId* id : *fixups->StringIds()) {
+ for (dex_ir::StringId* id : fixups->StringIds()) {
from_hot_method[id->GetIndex()] = true;
}
// Add field classes, names, and types.
- for (dex_ir::FieldId* id : *fixups->FieldIds()) {
+ for (dex_ir::FieldId* id : fixups->FieldIds()) {
// TODO: Only visit field ids from static getters and setters.
from_hot_method[id->Class()->GetStringId()->GetIndex()] = true;
from_hot_method[id->Name()->GetIndex()] = true;
@@ -1668,7 +1668,7 @@
}
// For clinits, add referenced method classes, names, and protos.
if (is_clinit) {
- for (dex_ir::MethodId* id : *fixups->MethodIds()) {
+ for (dex_ir::MethodId* id : fixups->MethodIds()) {
from_hot_method[id->Class()->GetStringId()->GetIndex()] = true;
from_hot_method[id->Name()->GetIndex()] = true;
is_shorty[id->Proto()->Shorty()->GetIndex()] = true;