From a504ac3e2a57654b96501b3a1ba80f37b3381dc8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 10 Mar 2023 08:48:54 +0100 Subject: Everywhere: Rename equals_ignoring_case => equals_ignoring_ascii_case Let's make it clear that these functions deal with ASCII case only. --- AK/StringView.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'AK/StringView.h') diff --git a/AK/StringView.h b/AK/StringView.h index dd6fe9540e..aeccf623c4 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -104,7 +104,7 @@ public: [[nodiscard]] bool contains(char) const; [[nodiscard]] bool contains(u32) const; [[nodiscard]] bool contains(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const; - [[nodiscard]] bool equals_ignoring_case(StringView other) const; + [[nodiscard]] bool equals_ignoring_ascii_case(StringView) const; [[nodiscard]] StringView trim(StringView characters, TrimMode mode = TrimMode::Both) const { return StringUtils::trim(*this, characters, mode); } [[nodiscard]] StringView trim_whitespace(TrimMode mode = TrimMode::Both) const { return StringUtils::trim_whitespace(*this, mode); } @@ -337,14 +337,14 @@ public: } template - [[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of_ignoring_case(Ts&&... strings) const + [[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of_ignoring_ascii_case(Ts&&... strings) const { return (... || [this, &strings]() -> bool { if constexpr (requires(Ts a) { a.view()->StringView; }) - return this->equals_ignoring_case(forward(strings.view())); + return this->equals_ignoring_ascii_case(forward(strings.view())); else - return this->equals_ignoring_case(forward(strings)); + return this->equals_ignoring_ascii_case(forward(strings)); }()); } @@ -359,6 +359,7 @@ struct Traits : public GenericTraits { static unsigned hash(StringView s) { return s.hash(); } }; +// FIXME: Rename this to indicate that it's about ASCII-only case insensitivity. struct CaseInsensitiveStringViewTraits : public Traits { static unsigned hash(StringView s) { @@ -366,7 +367,7 @@ struct CaseInsensitiveStringViewTraits : public Traits { return 0; return case_insensitive_string_hash(s.characters_without_null_termination(), s.length()); } - static bool equals(StringView const& a, StringView const& b) { return a.equals_ignoring_case(b); } + static bool equals(StringView const& a, StringView const& b) { return a.equals_ignoring_ascii_case(b); } }; } -- cgit v1.2.3