mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Make StringView::contains(StringView) faster for 1-byte needles
If we're looking for a 1-byte string, we can do the much simpler byte scan by simply forwarding the call to StringView::contains(char).
This commit is contained in:
parent
6c51ba27a2
commit
bacbc376a0
Notes:
sideshowbarker
2024-07-17 18:46:57 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/bacbc376a0 Pull-request: https://github.com/SerenityOS/serenity/pull/22496 Reviewed-by: https://github.com/LucasChollet
1 changed files with 2 additions and 0 deletions
|
@ -167,6 +167,8 @@ bool StringView::contains(u32 needle) const
|
|||
|
||||
bool StringView::contains(StringView needle, CaseSensitivity case_sensitivity) const
|
||||
{
|
||||
if (needle.length() == 1)
|
||||
return contains(needle.characters_without_null_termination()[0]);
|
||||
return StringUtils::contains(*this, needle, case_sensitivity);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue