mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-24 19:28:48 +00:00
AK: Implement a flyweight string for Utf16String
Utf16FlyString more or less works exactly the same as FlyString. It will store the raw encoded data of the string instance. If the string is a short ASCII string, Utf16FlyString holds the ShortString bytes; else, Utf16FlyString holds a pointer to the Utf16StringData.
This commit is contained in:
parent
2803d66d87
commit
7f069efbc4
Notes:
github-actions[bot]
2025-07-18 16:47:19 +00:00
Author: https://github.com/trflynn89
Commit: 7f069efbc4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5388
Reviewed-by: https://github.com/shannonbooth ✅
9 changed files with 423 additions and 4 deletions
|
@ -248,6 +248,21 @@ public:
|
|||
return !has_short_ascii_storage();
|
||||
}
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE Utf16StringData const* data(Badge<Utf16FlyString>) const
|
||||
{
|
||||
VERIFY(has_long_storage());
|
||||
return data_without_union_member_assertion();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void set_data(Badge<Utf16FlyString>, Utf16StringData const* data)
|
||||
{
|
||||
auto const** this_data = __builtin_launder(&m_value.data);
|
||||
(*this_data) = data;
|
||||
(*this_data)->ref();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr FlatPtr raw(Badge<Utf16FlyString>) const { return bit_cast<FlatPtr>(m_value); }
|
||||
|
||||
protected:
|
||||
ALWAYS_INLINE void destroy_string() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue