diff options
Diffstat (limited to 'runtime/intern_table.cc')
| -rw-r--r-- | runtime/intern_table.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/runtime/intern_table.cc b/runtime/intern_table.cc index eceb593e08..1940d67316 100644 --- a/runtime/intern_table.cc +++ b/runtime/intern_table.cc @@ -386,8 +386,23 @@ bool InternTable::StringHashEquals::operator()(const GcRoot<mirror::String>& a, if (a_length != b.GetUtf16Length()) { return false; } - const uint16_t* a_value = a_string->GetValue(); - return CompareModifiedUtf8ToUtf16AsCodePointValues(b.GetUtf8Data(), a_value, a_length) == 0; + if (a_string->IsCompressed()) { + size_t b_byte_count = strlen(b.GetUtf8Data()); + size_t b_utf8_length = CountModifiedUtf8Chars(b.GetUtf8Data(), b_byte_count); + // Modified UTF-8 single byte character range is 0x01 .. 0x7f + // The string compression occurs on regular ASCII with same exact range, + // not on extended ASCII which up to 0xff + const bool is_b_regular_ascii = (b_byte_count == b_utf8_length); + if (is_b_regular_ascii) { + return memcmp(b.GetUtf8Data(), + a_string->GetValueCompressed(), a_length * sizeof(uint8_t)) == 0; + } else { + return false; + } + } else { + const uint16_t* a_value = a_string->GetValue(); + return CompareModifiedUtf8ToUtf16AsCodePointValues(b.GetUtf8Data(), a_value, a_length) == 0; + } } size_t InternTable::Table::AddTableFromMemory(const uint8_t* ptr) { |