mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
AK: Use StringView::find() in StringView::split_view()
This fixes #4926.
This commit is contained in:
parent
39442e6d4f
commit
4fe27ec2a7
Notes:
sideshowbarker
2024-07-18 23:53:00 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/4fe27ec2a77 Pull-request: https://github.com/SerenityOS/serenity/pull/4929 Issue: https://github.com/SerenityOS/serenity/issues/4926
1 changed files with 2 additions and 2 deletions
|
@ -86,14 +86,14 @@ Vector<StringView> StringView::split_view(const StringView& separator, bool keep
|
|||
|
||||
Vector<StringView> parts;
|
||||
|
||||
auto maybe_separator_index = find_first_of(separator);
|
||||
auto maybe_separator_index = find(separator);
|
||||
while (maybe_separator_index.has_value()) {
|
||||
auto separator_index = maybe_separator_index.value();
|
||||
auto part_with_separator = view.substring_view(0, separator_index + separator.length());
|
||||
if (keep_empty || separator_index > 0)
|
||||
parts.append(part_with_separator.substring_view(0, separator_index));
|
||||
view = view.substring_view_starting_after_substring(part_with_separator);
|
||||
maybe_separator_index = view.find_first_of(separator);
|
||||
maybe_separator_index = view.find(separator);
|
||||
}
|
||||
if (keep_empty || !view.is_empty())
|
||||
parts.append(view);
|
||||
|
|
Loading…
Reference in a new issue