1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 04:17:34 +00:00

LibRegex: Avoid making unnecessary string copies

This commit is contained in:
Gunnar Beutner 2021-06-13 22:30:02 +02:00 committed by Ali Mohammad Pur
parent 281f39073d
commit 214410b397

View file

@ -528,15 +528,13 @@ ALWAYS_INLINE bool OpCode_Compare::compare_string(const MatchInput& input, Match
auto str_view1 = StringView(str, length); auto str_view1 = StringView(str, length);
auto str_view2 = StringView(&input.view.u8view()[state.string_position], length); auto str_view2 = StringView(&input.view.u8view()[state.string_position], length);
String str1, str2; bool string_equals;
if (input.regex_options & AllFlags::Insensitive) { if (input.regex_options & AllFlags::Insensitive)
str1 = str_view1.to_string().to_lowercase(); string_equals = str_view1.equals_ignoring_case(str_view2);
str2 = str_view2.to_string().to_lowercase(); else
str_view1 = str1.view(); string_equals = str_view1 == str_view2;
str_view2 = str2.view();
}
if (str_view1 == str_view2) { if (string_equals) {
state.string_position += length; state.string_position += length;
if (length == 0) if (length == 0)
had_zero_length_match = true; had_zero_length_match = true;