mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 07:34:57 +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
|
@ -238,14 +238,6 @@ bool StringView::operator==(const String& string) const
|
|||
return !__builtin_memcmp(m_characters, string.characters(), m_length);
|
||||
}
|
||||
|
||||
Optional<size_t> StringView::find_first_of(char c) const
|
||||
{
|
||||
if (const auto location = AK::find(begin(), end(), c); location != end()) {
|
||||
return location.index();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<size_t> StringView::find_first_of(const StringView& view) const
|
||||
{
|
||||
if (const auto location = AK::find_if(begin(), end(),
|
||||
|
@ -261,15 +253,6 @@ Optional<size_t> StringView::find_first_of(const StringView& view) const
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<size_t> StringView::find_last_of(char c) const
|
||||
{
|
||||
for (size_t pos = m_length; pos != 0; --pos) {
|
||||
if (m_characters[pos - 1] == c)
|
||||
return pos - 1;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<size_t> StringView::find_last_of(const StringView& view) const
|
||||
{
|
||||
for (size_t pos = m_length; pos != 0; --pos) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue