mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 13:58:11 +00:00
AK: Unify FlyString/StringView::ends_with implementation on StringUtils::ends_with
This creates a unified implementation of ends_with with case sensitivity across String/StringView/FlyString.
This commit is contained in:
parent
332f96e7ca
commit
129462cca7
4 changed files with 9 additions and 9 deletions
|
@ -141,15 +141,9 @@ bool StringView::ends_with(char ch) const
|
|||
return ch == characters_without_null_termination()[length() - 1];
|
||||
}
|
||||
|
||||
bool StringView::ends_with(const StringView& str) const
|
||||
bool StringView::ends_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;
|
||||
return !memcmp(characters_without_null_termination() + length() - str.length(), str.characters_without_null_termination(), str.length());
|
||||
return StringUtils::ends_with(*this, str, case_sensitivity);
|
||||
}
|
||||
|
||||
bool StringView::matches(const StringView& mask, CaseSensitivity case_sensitivity) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue