1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:17:44 +00:00

AK+Everywhere: Consolidate String::index_of() and String::find()

We had two functions for doing mostly the same thing. Combine both
of them into String::find() and use that everywhere.

Also add some tests to cover basic behavior.
This commit is contained in:
Andreas Kling 2021-05-24 11:50:46 +02:00
parent 875a2cbb71
commit de395a3df2
12 changed files with 36 additions and 30 deletions

View file

@ -127,13 +127,12 @@ public:
[[nodiscard]] bool equals_ignoring_case(const StringView&) const;
[[nodiscard]] bool contains(const StringView&, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
[[nodiscard]] Optional<size_t> index_of(const String&, size_t start = 0) const;
[[nodiscard]] Vector<String> split_limit(char separator, size_t limit, bool keep_empty = false) const;
[[nodiscard]] Vector<String> split(char separator, bool keep_empty = false) const;
[[nodiscard]] Optional<size_t> find(char) const;
[[nodiscard]] Optional<size_t> find(const StringView&) const;
[[nodiscard]] Optional<size_t> find(char, size_t start = 0) const;
[[nodiscard]] Optional<size_t> find(StringView const&, size_t start = 0) const;
[[nodiscard]] String substring(size_t start) const;
[[nodiscard]] String substring(size_t start, size_t length) const;