|
@@ -286,18 +286,6 @@ bool String::contains(const StringView& needle, CaseSensitivity case_sensitivity
|
|
|
return StringUtils::contains(*this, needle, case_sensitivity);
|
|
|
}
|
|
|
|
|
|
-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 + start, needle.characters());
|
|
|
- if (!result)
|
|
|
- return {};
|
|
|
- return Optional<size_t> { result - self_characters };
|
|
|
-}
|
|
|
-
|
|
|
bool String::equals_ignoring_case(const StringView& other) const
|
|
|
{
|
|
|
return StringUtils::equals_ignoring_case(view(), other);
|
|
@@ -491,14 +479,17 @@ String String::vformatted(StringView fmtstr, TypeErasedFormatParams params)
|
|
|
return builder.to_string();
|
|
|
}
|
|
|
|
|
|
-Optional<size_t> String::find(char c) const
|
|
|
+Optional<size_t> String::find(char c, size_t start) const
|
|
|
{
|
|
|
- return find(StringView { &c, 1 });
|
|
|
+ return find(StringView { &c, 1 }, start);
|
|
|
}
|
|
|
|
|
|
-Optional<size_t> String::find(const StringView& view) const
|
|
|
+Optional<size_t> String::find(StringView const& view, size_t start) const
|
|
|
{
|
|
|
- return StringUtils::find(*this, view);
|
|
|
+ auto index = StringUtils::find(substring_view(start), view);
|
|
|
+ if (!index.has_value())
|
|
|
+ return {};
|
|
|
+ return index.value() + start;
|
|
|
}
|
|
|
|
|
|
}
|