Use factory pattern for dex_ir objects
In preparation for memory improvements, make dex_ir API more friendly to
pre-allocated or in-place type allocation.
Bug: 33017139
Test: make -j 50 test-art-host
Change-Id: I09b67e279a04535b175433287ce98ecbdc37f7a3
diff --git a/dexlayout/compact_dex_writer.cc b/dexlayout/compact_dex_writer.cc
index 2b4144c..3f5dbcf 100644
--- a/dexlayout/compact_dex_writer.cc
+++ b/dexlayout/compact_dex_writer.cc
@@ -59,8 +59,8 @@
for (auto& method : *(invoke_type == InvokeType::kDirect
? class_data->DirectMethods()
: class_data->VirtualMethods())) {
- const dex_ir::MethodId* method_id = method->GetMethodId();
- dex_ir::CodeItem* code_item = method->GetCodeItem();
+ const dex_ir::MethodId* method_id = method.GetMethodId();
+ dex_ir::CodeItem* code_item = method.GetCodeItem();
if (code_item != nullptr && code_item->DebugInfo() != nullptr) {
const uint32_t debug_info_offset = code_item->DebugInfo()->GetOffset();
const uint32_t method_idx = method_id->GetIndex();
@@ -248,8 +248,8 @@
for (auto& method : *(invoke_type == InvokeType::kDirect
? class_data->DirectMethods()
: class_data->VirtualMethods())) {
- const dex_ir::MethodId* method_id = method->GetMethodId();
- dex_ir::CodeItem* code_item = method->GetCodeItem();
+ const dex_ir::MethodId* method_id = method.GetMethodId();
+ dex_ir::CodeItem* code_item = method.GetCodeItem();
if (code_item != nullptr && code_item->DebugInfo() != nullptr) {
const dex_ir::DebugInfoItem* debug_item = code_item->DebugInfo();
method_idx_map.insert(std::make_pair(debug_item, method_id->GetIndex()));
@@ -350,8 +350,8 @@
for (auto& method : *(invoke_type == InvokeType::kDirect
? class_data->DirectMethods()
: class_data->VirtualMethods())) {
- const uint32_t idx = method->GetMethodId()->GetIndex();
- dex_ir::CodeItem* code_item = method->GetCodeItem();
+ const uint32_t idx = method.GetMethodId()->GetIndex();
+ dex_ir::CodeItem* code_item = method.GetCodeItem();
dex_ir:: DebugInfoItem* debug_info_item = nullptr;
if (code_item != nullptr) {
debug_info_item = code_item->DebugInfo();