mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-29 04:37:55 +00:00
LibRegex: Add the literal string search optimisation
This switches to using a simple string equality check if the regex pattern is strictly a string literal. Technically this optimisation can also be made on bounded literal patterns like /[abc]def/ or /abc|def/ as well, but those are significantly more complex to implement due to our bytecode-only approach.
This commit is contained in:
committed by
Andreas Kling
parent
221c52c696
commit
18f4b6c670
@@ -900,9 +900,8 @@ Vector<CompareTypeAndValuePair> OpCode_Compare::flat_compares() const
|
||||
result.append({ compare_type, ref });
|
||||
} else if (compare_type == CharacterCompareType::String) {
|
||||
auto& length = m_bytecode->at(offset++);
|
||||
if (length > 0)
|
||||
result.append({ compare_type, m_bytecode->at(offset) });
|
||||
StringBuilder str_builder;
|
||||
for (size_t k = 0; k < length; ++k)
|
||||
result.append({ CharacterCompareType::Char, m_bytecode->at(offset + k) });
|
||||
offset += length;
|
||||
} else if (compare_type == CharacterCompareType::CharClass) {
|
||||
auto character_class = m_bytecode->at(offset++);
|
||||
|
||||
Reference in New Issue
Block a user