diff --git a/AK/FlyString.h b/AK/FlyString.h index 2db89366dfd..778d448b3d3 100644 --- a/AK/FlyString.h +++ b/AK/FlyString.h @@ -76,17 +76,13 @@ public: static void did_destroy_impl(Badge, StringImpl&); - template - bool is_one_of(const T& string, Rest... rest) const + template + [[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of(Ts... strings) const { - if (*this == string) - return true; - return is_one_of(rest...); + return (... || this->operator==(forward(strings))); } private: - bool is_one_of() const { return false; } - RefPtr m_impl; }; diff --git a/AK/String.h b/AK/String.h index b1d453e60dc..6f9b98fdde7 100644 --- a/AK/String.h +++ b/AK/String.h @@ -282,17 +282,13 @@ public: Vector find_all(const String& needle) const; [[nodiscard]] String reverse() const; - template - [[nodiscard]] bool is_one_of(const T& string, Rest... rest) const + template + [[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of(Ts... strings) const { - if (*this == string) - return true; - return is_one_of(rest...); + return (... || this->operator==(forward(strings))); } private: - [[nodiscard]] bool is_one_of() const { return false; } - RefPtr m_impl; }; diff --git a/AK/StringView.h b/AK/StringView.h index d7738f08ed7..78dfa8494da 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -209,17 +209,13 @@ public: [[nodiscard]] bool is_whitespace() const { return StringUtils::is_whitespace(*this); } - template - [[nodiscard]] bool is_one_of(const T& string, Rest... rest) const + template + [[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of(Ts... strings) const { - if (*this == string) - return true; - return is_one_of(rest...); + return (... || this->operator==(forward(strings))); } private: - [[nodiscard]] bool is_one_of() const { return false; } - friend class String; const char* m_characters { nullptr }; size_t m_length { 0 };