mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:24:58 +00:00
AK: Use an enum instead of a bool for String::replace(all_occurences)
This commit has no behavior changes. In particular, this does not fix any of the wrong uses of the previous default parameter (which used to be 'false', meaning "only replace the first occurence in the string"). It simply replaces the default uses by String::replace(..., ReplaceMode::FirstOnly), leaving them incorrect.
This commit is contained in:
parent
b2454888e8
commit
7ceeb74535
47 changed files with 108 additions and 102 deletions
|
@ -476,13 +476,13 @@ String invert_case(StringView str)
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
String replace(StringView str, StringView needle, StringView replacement, bool all_occurrences)
|
||||
String replace(StringView str, StringView needle, StringView replacement, ReplaceMode replace_mode)
|
||||
{
|
||||
if (str.is_empty())
|
||||
return str;
|
||||
|
||||
Vector<size_t> positions;
|
||||
if (all_occurrences) {
|
||||
if (replace_mode == ReplaceMode::All) {
|
||||
positions = str.find_all(needle);
|
||||
if (!positions.size())
|
||||
return str;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue