mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
AK: Add case insensitive version of starts_with
This commit is contained in:
parent
ccc929dcf9
commit
a5ecb9bd6b
Notes:
sideshowbarker
2024-07-19 04:42:15 +09:00
Author: https://github.com/Lubrsi
Commit: a5ecb9bd6b
Pull-request: https://github.com/SerenityOS/serenity/pull/2842
11 changed files with 53 additions and 20 deletions
|
@ -147,17 +147,9 @@ bool StringView::starts_with(char ch) const
|
|||
return ch == characters_without_null_termination()[0];
|
||||
}
|
||||
|
||||
bool StringView::starts_with(const StringView& str) const
|
||||
bool StringView::starts_with(const StringView& str, CaseSensitivity case_sensitivity) const
|
||||
{
|
||||
if (str.is_empty())
|
||||
return true;
|
||||
if (is_empty())
|
||||
return false;
|
||||
if (str.length() > length())
|
||||
return false;
|
||||
if (characters_without_null_termination() == str.characters_without_null_termination())
|
||||
return true;
|
||||
return !memcmp(characters_without_null_termination(), str.characters_without_null_termination(), str.length());
|
||||
return StringUtils::starts_with(*this, str, case_sensitivity);
|
||||
}
|
||||
|
||||
bool StringView::ends_with(char ch) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue