mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 15:17:45 +00:00
LibRegex: Avoid creating a new temporary RegexStringView in Char compare
Instead of making a new string to compare against, simply grab the first code unit of the input and compare against that.
This commit is contained in:
parent
6a7739c645
commit
c80b65b827
1 changed files with 3 additions and 6 deletions
|
@ -555,15 +555,12 @@ ALWAYS_INLINE void OpCode_Compare::compare_char(MatchInput const& input, MatchSt
|
||||||
if (state.string_position == input.view.length())
|
if (state.string_position == input.view.length())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto input_view = input.view.substring_view(state.string_position, 1);
|
auto input_view = input.view.substring_view(state.string_position, 1)[0];
|
||||||
Optional<String> str;
|
|
||||||
Vector<u16, 1> utf16;
|
|
||||||
auto compare_view = input_view.construct_as_same({ &ch1, 1 }, str, utf16);
|
|
||||||
bool equal;
|
bool equal;
|
||||||
if (input.regex_options & AllFlags::Insensitive)
|
if (input.regex_options & AllFlags::Insensitive)
|
||||||
equal = input_view.equals_ignoring_case(compare_view);
|
equal = to_ascii_lowercase(input_view) == to_ascii_lowercase(ch1); // FIXME: Implement case-insensitive matching for non-ascii characters
|
||||||
else
|
else
|
||||||
equal = input_view.equals(compare_view);
|
equal = input_view == ch1;
|
||||||
|
|
||||||
if (equal) {
|
if (equal) {
|
||||||
if (inverse)
|
if (inverse)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue