mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
AK: Make String const-correct internally
This commit is contained in:
parent
a56dfd5c77
commit
e08c55dd8d
Notes:
sideshowbarker
2024-07-17 03:25:24 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e08c55dd8d Pull-request: https://github.com/SerenityOS/serenity/pull/17557 Reviewed-by: https://github.com/linusg
2 changed files with 6 additions and 6 deletions
|
@ -63,7 +63,7 @@ public:
|
|||
}
|
||||
|
||||
bool is_fly_string() const { return m_is_fly_string; }
|
||||
void set_fly_string(bool is_fly_string) { m_is_fly_string = is_fly_string; }
|
||||
void set_fly_string(bool is_fly_string) const { m_is_fly_string = is_fly_string; }
|
||||
|
||||
private:
|
||||
explicit StringData(size_t byte_count);
|
||||
|
@ -75,7 +75,7 @@ private:
|
|||
mutable unsigned m_hash { 0 };
|
||||
mutable bool m_has_hash { false };
|
||||
bool m_substring { false };
|
||||
bool m_is_fly_string { false };
|
||||
mutable bool m_is_fly_string { false };
|
||||
|
||||
alignas(SubstringData) u8 m_bytes_or_substring_data[0];
|
||||
};
|
||||
|
@ -165,7 +165,7 @@ void StringData::compute_hash() const
|
|||
|
||||
}
|
||||
|
||||
String::String(NonnullRefPtr<Detail::StringData> data)
|
||||
String::String(NonnullRefPtr<Detail::StringData const> data)
|
||||
: m_data(&data.leak_ref())
|
||||
{
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ String String::fly_string_data_to_string(Badge<FlyString>, uintptr_t const& data
|
|||
return String { *reinterpret_cast<ShortString const*>(&data) };
|
||||
|
||||
auto const* string_data = reinterpret_cast<Detail::StringData const*>(data);
|
||||
return String { NonnullRefPtr<Detail::StringData>(*string_data) };
|
||||
return String { NonnullRefPtr<Detail::StringData const>(*string_data) };
|
||||
}
|
||||
|
||||
StringView String::fly_string_data_to_string_view(Badge<FlyString>, uintptr_t const& data)
|
||||
|
|
|
@ -230,7 +230,7 @@ private:
|
|||
u8 storage[MAX_SHORT_STRING_BYTE_COUNT] = { 0 };
|
||||
};
|
||||
|
||||
explicit String(NonnullRefPtr<Detail::StringData>);
|
||||
explicit String(NonnullRefPtr<Detail::StringData const>);
|
||||
|
||||
explicit constexpr String(ShortString short_string)
|
||||
: m_short_string(short_string)
|
||||
|
@ -241,7 +241,7 @@ private:
|
|||
|
||||
union {
|
||||
ShortString m_short_string;
|
||||
Detail::StringData* m_data { nullptr };
|
||||
Detail::StringData const* m_data { nullptr };
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue