1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:07:46 +00:00

AK: Add String::starts_with to match String::ends_with

This commit is contained in:
Conrad Pankoff 2019-06-04 21:53:25 +10:00 committed by Andreas Kling
parent 738f9de9a9
commit 419e886497
2 changed files with 12 additions and 0 deletions

View file

@ -180,6 +180,17 @@ String String::format(const char* fmt, ...)
return builder.to_string();
}
bool String::starts_with(const StringView& str) const
{
if (str.is_empty())
return true;
if (is_empty())
return false;
if (str.length() > length())
return false;
return !memcmp(characters(), str.characters(), str.length());
}
bool String::ends_with(const StringView& str) const
{
if (str.is_empty())