diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-08-02 06:57:10 -0400 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-08-02 21:02:09 +0430 |
commit | dc9f516339be8850bbc0b4a1cc2051a72bf9b07a (patch) | |
tree | 6eb53c1b41eb33056dcd459cbf5e2f0417f5a4a0 /Userland/Libraries/LibRegex/RegexParser.cpp | |
parent | 4de43128275ed08fba70eaa732eab34fd39f23b8 (diff) | |
download | serenity-dc9f516339be8850bbc0b4a1cc2051a72bf9b07a.zip |
LibRegex: Generate negated property escapes as a single instruction
These were previously generated as two instructions, Compare [Inverse]
and Compare [Property].
Diffstat (limited to 'Userland/Libraries/LibRegex/RegexParser.cpp')
-rw-r--r-- | Userland/Libraries/LibRegex/RegexParser.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Libraries/LibRegex/RegexParser.cpp b/Userland/Libraries/LibRegex/RegexParser.cpp index 10ac0d7fd1..3139afb80f 100644 --- a/Userland/Libraries/LibRegex/RegexParser.cpp +++ b/Userland/Libraries/LibRegex/RegexParser.cpp @@ -1546,15 +1546,18 @@ bool ECMA262Parser::parse_atom_escape(ByteCode& stack, size_t& match_length_mini bool negated = false; if (parse_unicode_property_escape(property, negated)) { + Vector<CompareTypeAndValuePair> compares; if (negated) - stack.insert_bytecode_compare_values({ { CharacterCompareType::Inverse, 0 } }); + compares.empend(CompareTypeAndValuePair { CharacterCompareType::Inverse, 0 }); property.visit( [&](Unicode::Property property) { - stack.insert_bytecode_compare_values({ { CharacterCompareType::Property, (ByteCodeValueType)(property) } }); + compares.empend(CompareTypeAndValuePair { CharacterCompareType::Property, (ByteCodeValueType)property }); }, [&](Unicode::GeneralCategory general_category) { - stack.insert_bytecode_compare_values({ { CharacterCompareType::GeneralCategory, (ByteCodeValueType)(general_category) } }); + compares.empend(CompareTypeAndValuePair { CharacterCompareType::GeneralCategory, (ByteCodeValueType)general_category }); }); + stack.insert_bytecode_compare_values(move(compares)); + match_length_minimum += 1; return true; } } |