1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 07:54:58 +00:00

AK: Forward substring creation with shared superstring to StringBase

This commit is contained in:
Dan Klishch 2023-10-28 17:50:24 -04:00 committed by Andrew Kaster
parent 5d6cd65e29
commit e7700e16ee
5 changed files with 34 additions and 5 deletions

View file

@ -252,11 +252,7 @@ ErrorOr<String> String::substring_from_byte_offset(size_t start) const
ErrorOr<String> String::substring_from_byte_offset_with_shared_superstring(size_t start, size_t byte_count) const
{
if (!byte_count)
return String {};
if (byte_count <= MAX_SHORT_STRING_BYTE_COUNT)
return String::from_utf8(bytes_as_string_view().substring_view(start, byte_count));
return String { TRY(Detail::StringData::create_substring(*m_data, start, byte_count)) };
return String { TRY(StringBase::substring_from_byte_offset_with_shared_superstring(start, byte_count)) };
}
ErrorOr<String> String::substring_from_byte_offset_with_shared_superstring(size_t start) const