From 3dd2fbd04118db179679225707b0f45d2be4fb14 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sun, 11 May 2025 23:17:29 -0600 Subject: [PATCH] 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 :^). --- Libraries/LibRegex/RegexByteCode.cpp | 13 ++++++++++++- Libraries/LibRegex/RegexByteCode.h | 14 ++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Libraries/LibRegex/RegexByteCode.cpp b/Libraries/LibRegex/RegexByteCode.cpp index 689b707035b..02576be31da 100644 --- a/Libraries/LibRegex/RegexByteCode.cpp +++ b/Libraries/LibRegex/RegexByteCode.cpp @@ -161,7 +161,18 @@ static bool restore_string_position(MatchInput const& input, MatchState& state) OwnPtr 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() { diff --git a/Libraries/LibRegex/RegexByteCode.h b/Libraries/LibRegex/RegexByteCode.h index 00ec76e8b4c..6a10de9bdca 100644 --- a/Libraries/LibRegex/RegexByteCode.h +++ b/Libraries/LibRegex/RegexByteCode.h @@ -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 m_table; HashMap m_inverse_table;