Merge "Try to avoid allocation when interning strings."
diff --git a/runtime/intern_table.cc b/runtime/intern_table.cc
index 1940d67..be061be 100644
--- a/runtime/intern_table.cc
+++ b/runtime/intern_table.cc
@@ -316,8 +316,14 @@
mirror::String* InternTable::InternStrong(int32_t utf16_length, const char* utf8_data) {
DCHECK(utf8_data != nullptr);
+ Thread* self = Thread::Current();
+ // Try to avoid allocation.
+ mirror::String* s = LookupStrong(self, utf16_length, utf8_data);
+ if (s != nullptr) {
+ return s;
+ }
return InternStrong(mirror::String::AllocFromModifiedUtf8(
- Thread::Current(), utf16_length, utf8_data));
+ self, utf16_length, utf8_data));
}
mirror::String* InternTable::InternStrong(const char* utf8_data) {