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:
Brian Gianforcaro 2020-05-26 03:21:34 -07:00 committed by Andreas Kling
commit 129462cca7
Notes: sideshowbarker 2024-07-19 06:07:37 +09:00
4 changed files with 9 additions and 9 deletions

View file

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