mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK: Give String::index_of() an optional second "start" argument
This commit is contained in:
parent
332f349e07
commit
97cea9e61c
Notes:
sideshowbarker
2024-07-19 04:52:02 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/97cea9e61cb Pull-request: https://github.com/SerenityOS/serenity/pull/2778
2 changed files with 3 additions and 3 deletions
|
@ -311,13 +311,13 @@ bool String::contains(const String& needle) const
|
|||
return strstr(characters(), needle.characters());
|
||||
}
|
||||
|
||||
Optional<size_t> String::index_of(const String& needle) const
|
||||
Optional<size_t> String::index_of(const String& needle, size_t start) const
|
||||
{
|
||||
if (is_null() || needle.is_null())
|
||||
return {};
|
||||
|
||||
const char* self_characters = characters();
|
||||
const char* result = strstr(self_characters, needle.characters());
|
||||
const char* result = strstr(self_characters + start, needle.characters());
|
||||
if (!result)
|
||||
return {};
|
||||
return Optional<size_t> { result - self_characters };
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
bool equals_ignoring_case(const StringView&) const;
|
||||
|
||||
bool contains(const String&) const;
|
||||
Optional<size_t> index_of(const String&) const;
|
||||
Optional<size_t> index_of(const String&, size_t start = 0) const;
|
||||
|
||||
Vector<String> split_limit(char separator, size_t limit, bool keep_empty = false) const;
|
||||
Vector<String> split(char separator, bool keep_empty = false) const;
|
||||
|
|
Loading…
Reference in a new issue