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:
Andrew Kaster 2025-05-11 23:17:29 -06:00 committed by Andrew Kaster
parent 8f670950e2
commit 3dd2fbd041
Notes: github-actions[bot] 2025-05-12 09:23:38 +00:00
2 changed files with 14 additions and 13 deletions

View file

@ -161,7 +161,18 @@ static bool restore_string_position(MatchInput const& input, MatchState& state)
OwnPtr<OpCode> ByteCode::s_opcodes[(size_t)OpCodeId::Last + 1];
bool ByteCode::s_opcodes_initialized { false };
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()
{

View file

@ -143,19 +143,10 @@ struct CompareTypeAndValuePair {
class OpCode;
struct StringTable {
StringTable()
: m_serial(next_serial++)
{
}
StringTable();
~StringTable();
StringTable(StringTable const&) = 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&&) = default;
@ -180,7 +171,6 @@ struct StringTable {
return m_inverse_table.get(index).value();
}
static u32 next_serial;
u32 m_serial { 0 };
HashMap<FlyString, ByteCodeValueType> m_table;
HashMap<ByteCodeValueType, FlyString> m_inverse_table;