AK: Add FlyString::equals_ignoring_ascii_case()

This is similar to equals_ignoring_case() but only cares about ASCII
case insensitivity.
This commit is contained in:
Andreas Kling 2023-03-07 19:53:21 +01:00
parent b78ee64415
commit 629b6462dc
Notes: sideshowbarker 2024-07-17 11:06:06 +09:00
2 changed files with 11 additions and 0 deletions

View File

@ -178,4 +178,12 @@ ErrorOr<void> Formatter<FlyString>::format(FormatBuilder& builder, FlyString con
return Formatter<StringView>::format(builder, fly_string.bytes_as_string_view());
}
bool FlyString::equals_ignoring_ascii_case(FlyString const& other) const
{
if (*this == other)
return true;
// FIXME: Rename StringUtils::equals_ignoring_case to equals_ignoring_ascii_case.
return StringUtils::equals_ignoring_case(bytes_as_string_view(), other.bytes_as_string_view());
}
}

View File

@ -54,6 +54,9 @@ public:
// FIXME: Remove this once all code has been ported to FlyString
[[nodiscard]] DeprecatedFlyString to_deprecated_fly_string() const;
// Compare this FlyString against another string with ASCII caseless matching.
[[nodiscard]] bool equals_ignoring_ascii_case(FlyString const&) const;
private:
// This will hold either the pointer to the Detail::StringData it represents or the raw bytes of
// an inlined short string.