AK: Add case insensitive version of starts_with

This commit is contained in:
Luke 2020-07-18 17:59:38 +01:00 committed by Andreas Kling
commit a5ecb9bd6b
Notes: sideshowbarker 2024-07-19 04:42:15 +09:00
11 changed files with 53 additions and 20 deletions

View file

@ -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