mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 07:22:21 +00:00
LibRegex: Move StringTable ctor/dtor out of line
This also moves the next_serial class static into a file scope static. The public class static was causing visibility issues with certain Linux builds when hidden visibility was enabled. However, the current design makes more sense anyway :^).
This commit is contained in:
parent
8f670950e2
commit
3dd2fbd041
Notes:
github-actions[bot]
2025-05-12 09:23:38 +00:00
Author: https://github.com/ayeteadoe
Commit: 3dd2fbd041
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4667
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/alimpfard
2 changed files with 14 additions and 13 deletions
|
@ -161,7 +161,18 @@ static bool restore_string_position(MatchInput const& input, MatchState& state)
|
||||||
OwnPtr<OpCode> ByteCode::s_opcodes[(size_t)OpCodeId::Last + 1];
|
OwnPtr<OpCode> ByteCode::s_opcodes[(size_t)OpCodeId::Last + 1];
|
||||||
bool ByteCode::s_opcodes_initialized { false };
|
bool ByteCode::s_opcodes_initialized { false };
|
||||||
size_t ByteCode::s_next_checkpoint_serial_id { 0 };
|
size_t ByteCode::s_next_checkpoint_serial_id { 0 };
|
||||||
u32 StringTable::next_serial { 0 };
|
static u32 s_next_string_table_serial { 0 };
|
||||||
|
|
||||||
|
StringTable::StringTable()
|
||||||
|
: m_serial(s_next_string_table_serial++)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
StringTable::~StringTable()
|
||||||
|
{
|
||||||
|
if (m_serial == s_next_string_table_serial - 1 && m_table.is_empty())
|
||||||
|
--s_next_string_table_serial; // We didn't use this serial, put it back.
|
||||||
|
}
|
||||||
|
|
||||||
void ByteCode::ensure_opcodes_initialized()
|
void ByteCode::ensure_opcodes_initialized()
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,19 +143,10 @@ struct CompareTypeAndValuePair {
|
||||||
class OpCode;
|
class OpCode;
|
||||||
|
|
||||||
struct StringTable {
|
struct StringTable {
|
||||||
StringTable()
|
StringTable();
|
||||||
: m_serial(next_serial++)
|
~StringTable();
|
||||||
{
|
|
||||||
}
|
|
||||||
StringTable(StringTable const&) = default;
|
StringTable(StringTable const&) = default;
|
||||||
StringTable(StringTable&&) = default;
|
StringTable(StringTable&&) = default;
|
||||||
|
|
||||||
~StringTable()
|
|
||||||
{
|
|
||||||
if (m_serial == next_serial - 1 && m_table.is_empty())
|
|
||||||
--next_serial; // We didn't use this serial, put it back.
|
|
||||||
}
|
|
||||||
|
|
||||||
StringTable& operator=(StringTable const&) = default;
|
StringTable& operator=(StringTable const&) = default;
|
||||||
StringTable& operator=(StringTable&&) = default;
|
StringTable& operator=(StringTable&&) = default;
|
||||||
|
|
||||||
|
@ -180,7 +171,6 @@ struct StringTable {
|
||||||
return m_inverse_table.get(index).value();
|
return m_inverse_table.get(index).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 next_serial;
|
|
||||||
u32 m_serial { 0 };
|
u32 m_serial { 0 };
|
||||||
HashMap<FlyString, ByteCodeValueType> m_table;
|
HashMap<FlyString, ByteCodeValueType> m_table;
|
||||||
HashMap<ByteCodeValueType, FlyString> m_inverse_table;
|
HashMap<ByteCodeValueType, FlyString> m_inverse_table;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue