summaryrefslogtreecommitdiffstats
path: root/runtime/oat_file.h
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2014-06-05 18:36:42 +0100
committerVladimir Marko <vmarko@google.com>2014-06-05 18:36:42 +0100
commit539690a351d8c325707368729aafa2b4fa134d4c (patch)
treea5297097077628b6092e71f01817a1d268a4620a /runtime/oat_file.h
parentd5e2b00cbc1e6b6608a5dbcfb05b7c4976614636 (diff)
downloadart-539690a351d8c325707368729aafa2b4fa134d4c.tar.gz
art-539690a351d8c325707368729aafa2b4fa134d4c.tar.bz2
art-539690a351d8c325707368729aafa2b4fa134d4c.zip
Avoid a memory allocation in OatFile::GetOatDexFile().
Use StringPiece instead of std::string as the map key. Change-Id: I05516d273de617a7d714e39ce6c4236cec6a09f7
Diffstat (limited to 'runtime/oat_file.h')
-rw-r--r--runtime/oat_file.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index d70373172e..eae0418c17 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -20,6 +20,7 @@
#include <string>
#include <vector>
+#include "base/stringpiece.h"
#include "dex_file.h"
#include "invoke_type.h"
#include "mem_map.h"
@@ -206,11 +207,11 @@ class OatFile {
const byte* dex_file_pointer,
const uint32_t* oat_class_offsets_pointer);
- const OatFile* oat_file_;
- std::string dex_file_location_;
- uint32_t dex_file_location_checksum_;
- const byte* dex_file_pointer_;
- const uint32_t* oat_class_offsets_pointer_;
+ const OatFile* const oat_file_;
+ const std::string dex_file_location_;
+ const uint32_t dex_file_location_checksum_;
+ const byte* const dex_file_pointer_;
+ const uint32_t* const oat_class_offsets_pointer_;
friend class OatFile;
DISALLOW_COPY_AND_ASSIGN(OatDexFile);
@@ -270,7 +271,9 @@ class OatFile {
// dlopen handle during runtime.
void* dlopen_handle_;
- typedef SafeMap<std::string, const OatDexFile*> Table;
+ // NOTE: We use a StringPiece as the key type to avoid a memory allocation on every lookup
+ // with a const char* key.
+ typedef SafeMap<StringPiece, const OatDexFile*> Table;
Table oat_dex_files_;
friend class OatClass;