diff options
author | Vladimir Marko <vmarko@google.com> | 2013-11-21 15:49:16 +0000 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2013-11-21 17:24:18 +0000 |
commit | e9c36b34efb7460f59c6766e526c9b0de8da70b3 (patch) | |
tree | 5694423b3debc675764f6364785090a6956bc371 /runtime/dex_file.cc | |
parent | 3e669dba962dc5291de0642eb46ede107be4e5a4 (diff) | |
download | art-e9c36b34efb7460f59c6766e526c9b0de8da70b3.tar.gz art-e9c36b34efb7460f59c6766e526c9b0de8da70b3.tar.bz2 art-e9c36b34efb7460f59c6766e526c9b0de8da70b3.zip |
Avoid some string allocations.
Also avoid building a string one character at a time.
Change-Id: I3db26226c620a730b95637d5bfc23e2d4715cfb9
Diffstat (limited to 'runtime/dex_file.cc')
-rw-r--r-- | runtime/dex_file.cc | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc index 0ddcdf30c9..a7575ce889 100644 --- a/runtime/dex_file.cc +++ b/runtime/dex_file.cc @@ -555,22 +555,19 @@ bool DexFile::CreateTypeList(const StringPiece& signature, uint16_t* return_type size_t end = signature.size(); bool process_return = false; while (offset < end) { + size_t start_offset = offset; char c = signature[offset]; offset++; if (c == ')') { process_return = true; continue; } - // TODO: avoid building a string. - std::string descriptor; - descriptor += c; while (c == '[') { // process array prefix if (offset >= end) { // expect some descriptor following [ return false; } c = signature[offset]; offset++; - descriptor += c; } if (c == 'L') { // process type descriptors do { @@ -579,9 +576,10 @@ bool DexFile::CreateTypeList(const StringPiece& signature, uint16_t* return_type } c = signature[offset]; offset++; - descriptor += c; } while (c != ';'); } + // TODO: avoid creating a std::string just to get a 0-terminated char array + std::string descriptor(signature.data() + start_offset, offset - start_offset); const DexFile::StringId* string_id = FindStringId(descriptor.c_str()); if (string_id == NULL) { return false; |