diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-06-04 14:16:29 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-04 12:57:14 +0200 |
commit | 824a40e95bc246ee9999ff0066e57383721e70c6 (patch) | |
tree | 2d4f299a53e9447d9f3d7788bd72467ac9835403 /AK/FlyString.h | |
parent | a446530c0dbf2952cccd8d17635ab40e7f54c736 (diff) | |
download | serenity-824a40e95bc246ee9999ff0066e57383721e70c6.zip |
AK: Inline *String::is_one_of<Ts...>()
Previously this was generating a crazy number of symbols, and it was
also pretty-damn-slow as it was defined recursively, which made the
compiler incapable of inlining it (due to the many many layers of
recursion before it terminated).
This commit replaces the recursion with a pack expansion and marks it
always-inline.
Diffstat (limited to 'AK/FlyString.h')
-rw-r--r-- | AK/FlyString.h | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/AK/FlyString.h b/AK/FlyString.h index 2db89366df..778d448b3d 100644 --- a/AK/FlyString.h +++ b/AK/FlyString.h @@ -76,17 +76,13 @@ public: static void did_destroy_impl(Badge<StringImpl>, StringImpl&); - template<typename T, typename... Rest> - bool is_one_of(const T& string, Rest... rest) const + template<typename... Ts> + [[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<Ts>(strings))); } private: - bool is_one_of() const { return false; } - RefPtr<StringImpl> m_impl; }; |