1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

LibJS: Reduce UTF-8 to UTF-16 transcoding when only UTF-16 is wanted

When appending two strings together to form a new string, if both of the
strings are already UTF-16, create the new string as UTF-16 as well.

This shaves about 0.5 seconds off the following test262 test:
  RegExp/property-escapes/generated/General_Category_-_Decimal_Number.js
This commit is contained in:
Timothy Flynn 2021-08-09 18:00:38 -04:00 committed by Andreas Kling
parent 66264f7c2a
commit b85b8ca350
2 changed files with 17 additions and 0 deletions

View file

@ -22,9 +22,11 @@ public:
PrimitiveString& operator=(PrimitiveString const&) = delete;
String const& string() const;
bool has_utf8_string() const { return m_has_utf8_string; }
Utf16String const& utf16_string() const;
Utf16View utf16_string_view() const;
bool has_utf16_string() const { return m_has_utf16_string; }
private:
virtual const char* class_name() const override { return "PrimitiveString"; }