Avoid a memory allocation in OatFile::GetOatDexFile().
Use StringPiece instead of std::string as the map key.
Change-Id: I05516d273de617a7d714e39ce6c4236cec6a09f7
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 74dfe91..6c44aa9 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -292,11 +292,14 @@
return false;
}
- oat_dex_files_.Put(dex_file_location, new OatDexFile(this,
- dex_file_location,
- dex_file_checksum,
- dex_file_pointer,
- methods_offsets_pointer));
+ OatDexFile* oat_dex_file = new OatDexFile(this,
+ dex_file_location,
+ dex_file_checksum,
+ dex_file_pointer,
+ methods_offsets_pointer);
+ // Use a StringPiece backed by the oat_dex_file's internal std::string as the key.
+ StringPiece key(oat_dex_file->GetDexFileLocation());
+ oat_dex_files_.Put(key, oat_dex_file);
}
return true;
}