diff options
| -rw-r--r-- | compiler/driver/compiler_driver.cc | 4 | ||||
| -rw-r--r-- | runtime/dex_file.cc | 8 | ||||
| -rw-r--r-- | runtime/hprof/hprof.cc | 2 |
3 files changed, 6 insertions, 8 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index b9df1d6f48..7b428793ab 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -697,11 +697,11 @@ void CompilerDriver::LoadImageClasses(TimingLogger& timings) ScopedObjectAccess soa(self); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); for (auto it = image_classes_->begin(), end = image_classes_->end(); it != end;) { - std::string descriptor(*it); + const std::string& descriptor(*it); SirtRef<mirror::Class> klass(self, class_linker->FindSystemClass(descriptor.c_str())); if (klass.get() == NULL) { - image_classes_->erase(it++); VLOG(compiler) << "Failed to find class " << descriptor; + image_classes_->erase(it++); self->ClearException(); } else { ++it; 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; diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc index 67620a09f1..9f899e87a3 100644 --- a/runtime/hprof/hprof.cc +++ b/runtime/hprof/hprof.cc @@ -537,7 +537,7 @@ class Hprof { HprofRecord* rec = ¤t_record_; for (StringMapIterator it = strings_.begin(); it != strings_.end(); ++it) { - std::string string((*it).first); + const std::string& string = (*it).first; size_t id = (*it).second; int err = current_record_.StartNewRecord(header_fp_, HPROF_TAG_STRING, HPROF_TIME); |