diff options
author | 2022-10-03 09:47:04 +0000 | |
---|---|---|
committer | 2022-10-03 14:19:38 +0000 | |
commit | 729277fa70c8a722e7ca7a319ecf9dc8a1ad9303 (patch) | |
tree | 9de7a4fcc4de31ce911829e89ff1726f0ee361c9 /runtime/mirror/string-alloc-inl.h | |
parent | 15294fe689c98f1b1314013a6ae17ee26b59aa07 (diff) |
Fix `String` ctor with `hibyte` for empty strings.
Mark empty strings as compressed for any value of `hibyte`.
Test: New test in 021-string2.
Test: testrunner.py --host --optimizing -t 021-string2
Bug: 250530521
Change-Id: Ie129fba599a24021eda0a4a81a39fd3fc3769597
Diffstat (limited to 'runtime/mirror/string-alloc-inl.h')
-rw-r--r-- | runtime/mirror/string-alloc-inl.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/runtime/mirror/string-alloc-inl.h b/runtime/mirror/string-alloc-inl.h index 533053d934..925427a73b 100644 --- a/runtime/mirror/string-alloc-inl.h +++ b/runtime/mirror/string-alloc-inl.h @@ -216,7 +216,9 @@ inline ObjPtr<String> String::AllocFromByteArray(Thread* self, const uint8_t* const src = reinterpret_cast<uint8_t*>(array->GetData()) + offset; high_byte &= 0xff; // Extract the relevant bits before determining `compressible`. const bool compressible = - kUseStringCompression && String::AllASCII<uint8_t>(src, byte_length) && (high_byte == 0); + kUseStringCompression && + String::AllASCII<uint8_t>(src, byte_length) && + (high_byte == 0 || byte_length == 0); const int32_t length_with_flag = String::GetFlaggedCount(byte_length, compressible); SetStringCountAndBytesVisitor visitor(length_with_flag, array, offset, high_byte << 8); return Alloc<kIsInstrumented>(self, length_with_flag, allocator_type, visitor); |