diff options
author | Max Wipfli <mail@maxwipfli.ch> | 2021-07-01 17:00:34 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-02 21:54:21 +0200 |
commit | d7a104c27c092b4f55133a72f35b54b64ebb8179 (patch) | |
tree | ffe7ca09b54a7d21ccf640faa2acc0272f14c3a4 /AK/String.h | |
parent | 3bdaed501e13a8b2dcdbbe2b5f4f68ffa22db59e (diff) | |
download | serenity-d7a104c27c092b4f55133a72f35b54b64ebb8179.zip |
AK: Implement StringView::find_all()
This implements the StringView::find_all() method by re-implemeting the
current method existing for String in StringUtils, and using that
implementation for both String and StringView.
The rewrite uses memmem() instead of strstr(), so the String::find_all()
argument type has been changed from String to StringView, as the null
byte is no longer required.
Diffstat (limited to 'AK/String.h')
-rw-r--r-- | AK/String.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/AK/String.h b/AK/String.h index a3e70ba803..6037e478ec 100644 --- a/AK/String.h +++ b/AK/String.h @@ -143,6 +143,7 @@ public: [[nodiscard]] Optional<size_t> find(char, size_t start = 0) const; [[nodiscard]] Optional<size_t> find(StringView const&, size_t start = 0) const; + [[nodiscard]] Vector<size_t> find_all(StringView const& needle) const { return StringUtils::find_all(*this, needle); } [[nodiscard]] String substring(size_t start) const; [[nodiscard]] String substring(size_t start, size_t length) const; @@ -279,7 +280,6 @@ public: int replace(const String& needle, const String& replacement, bool all_occurrences = false); size_t count(const String& needle) const; - Vector<size_t> find_all(const String& needle) const; [[nodiscard]] String reverse() const; template<typename... Ts> |