mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 17:31:58 -05:00
AK: Add String::find_last() and inline String::find() methods
This adds the String::find_last() as wrapper for StringUtils::find_last, which is another step in harmonizing the String and StringView APIs where possible. This also inlines the find() methods, as they are simple wrappers around StringUtils functions without any additional logic.
This commit is contained in:
parent
d7a104c27c
commit
268d81a56c
2 changed files with 4 additions and 12 deletions
|
@ -459,14 +459,4 @@ String String::vformatted(StringView fmtstr, TypeErasedFormatParams params)
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
Optional<size_t> String::find(char c, size_t start) const
|
||||
{
|
||||
return find(StringView { &c, 1 }, start);
|
||||
}
|
||||
|
||||
Optional<size_t> String::find(StringView const& view, size_t start) const
|
||||
{
|
||||
return StringUtils::find(*this, view, start);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -141,8 +141,10 @@ public:
|
|||
[[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, size_t start = 0) const;
|
||||
[[nodiscard]] Optional<size_t> find(StringView const&, size_t start = 0) 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]] Vector<size_t> find_all(StringView const& needle) const { return StringUtils::find_all(*this, needle); }
|
||||
|
||||
[[nodiscard]] String substring(size_t start) const;
|
||||
|
|
Loading…
Reference in a new issue