File tree 2 files changed +5
-3
lines changed
2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ ReadonlyBytes ShortString::bytes() const
18
18
19
19
size_t ShortString::byte_count () const
20
20
{
21
- return byte_count_and_short_string_flag >> 1 ;
21
+ return byte_count_and_short_string_flag >> StringBase::SHORT_STRING_BYTE_COUNT_SHIFT_COUNT ;
22
22
}
23
23
24
24
StringBase::StringBase (NonnullRefPtr<Detail::StringData const > data)
@@ -78,7 +78,7 @@ size_t StringBase::byte_count() const
78
78
{
79
79
ASSERT (!is_invalid ());
80
80
if (is_short_string ())
81
- return m_short_string.byte_count_and_short_string_flag >> 1 ;
81
+ return m_short_string.byte_count_and_short_string_flag >> StringBase::SHORT_STRING_BYTE_COUNT_SHIFT_COUNT ;
82
82
return m_data->byte_count ();
83
83
}
84
84
Original file line number Diff line number Diff line change @@ -103,9 +103,11 @@ class StringBase {
103
103
private:
104
104
friend class ::AK::String;
105
105
friend class ::AK::FlyString;
106
+ friend struct ::AK::Detail::ShortString;
106
107
107
108
// NOTE: If the least significant bit of the pointer is set, this is a short string.
108
109
static constexpr uintptr_t SHORT_STRING_FLAG = 1 ;
110
+ static constexpr unsigned SHORT_STRING_BYTE_COUNT_SHIFT_COUNT = 2 ;
109
111
110
112
explicit StringBase (NonnullRefPtr<Detail::StringData const >);
111
113
@@ -127,7 +129,7 @@ class StringBase {
127
129
VERIFY (byte_count <= MAX_SHORT_STRING_BYTE_COUNT);
128
130
129
131
m_short_string = ShortString {};
130
- m_short_string.byte_count_and_short_string_flag = (byte_count << 1 ) | SHORT_STRING_FLAG;
132
+ m_short_string.byte_count_and_short_string_flag = (byte_count << SHORT_STRING_BYTE_COUNT_SHIFT_COUNT ) | SHORT_STRING_FLAG;
131
133
return { m_short_string.storage , byte_count };
132
134
}
133
135
You can’t perform that action at this time.
0 commit comments