Replace ciCompareLen with ciStartsWith where possible

`ciCompareLen(a, b, b.size()) == 0` expression is an equivalent of checking for
equality of `a` prefix with size `b.size()` with `b`.

`ciCompareLen(a, b, a.size()) == 0` is also the same thing but `a` is a prefix
`b` should start with.
This commit is contained in:
elsid 2022-08-03 10:21:05 +02:00
parent bf0865d03d
commit 5dc612aa54
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
8 changed files with 45 additions and 12 deletions

View file

@ -28,6 +28,11 @@ namespace Misc::StringUtils
[] (char l, char r) { return toLower(l) == toLower(r); });
}
inline bool ciStartsWith(std::string_view value, std::string_view prefix)
{
return ciEqual(value.substr(0, prefix.size()), prefix);
}
inline int ciCompareLen(std::string_view x, std::string_view y, std::size_t len)
{
std::string_view::const_iterator xit = x.begin();