mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
AK+Everywhere: Remove StringView::find_{first,last}_of(char) methods
This removes StringView::find_first_of(char) and find_last_of(char) and replaces all its usages with find and find_last respectively. This is because those two methods are functionally equivalent. find_{first,last}_of should only be used if searching for multiple different characters, which is never the case with the char argument. This also adds the [[nodiscard]] to the remaining find_{first,last}_of methods.
This commit is contained in:
parent
56253bf389
commit
3bdaed501e
10 changed files with 41 additions and 68 deletions
|
@ -86,17 +86,14 @@ public:
|
|||
[[nodiscard]] String to_lowercase_string() const;
|
||||
[[nodiscard]] String to_uppercase_string() const;
|
||||
|
||||
Optional<size_t> find_first_of(char) const;
|
||||
Optional<size_t> find_first_of(const StringView&) const;
|
||||
|
||||
Optional<size_t> find_last_of(char) const;
|
||||
Optional<size_t> find_last_of(const StringView&) const;
|
||||
|
||||
[[nodiscard]] Optional<size_t> find(char needle, size_t start = 0) const { return StringUtils::find(*this, needle, start); }
|
||||
[[nodiscard]] Optional<size_t> find(StringView const& needle, size_t start = 0) const { return StringUtils::find(*this, needle, start); }
|
||||
[[nodiscard]] Optional<size_t> find_last(char needle) const { return StringUtils::find_last(*this, needle); }
|
||||
// FIXME: Implement find_last(StringView const&) for API symmetry.
|
||||
|
||||
[[nodiscard]] Optional<size_t> find_first_of(StringView const&) const;
|
||||
[[nodiscard]] Optional<size_t> find_last_of(StringView const&) const;
|
||||
|
||||
[[nodiscard]] constexpr StringView substring_view(size_t start, size_t length) const
|
||||
{
|
||||
if (!is_constant_evaluated())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue