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:
DexesTTP 2022-07-05 22:33:15 +02:00 committed by Linus Groh
parent b2454888e8
commit 7ceeb74535
Notes: sideshowbarker 2024-07-17 09:40:48 +09:00
47 changed files with 108 additions and 102 deletions

View file

@ -211,7 +211,7 @@ static void parse_dst_rule(StringView segment, TimeZoneOffset& time_zone)
static void parse_format(StringView format, TimeZoneData& time_zone_data, TimeZoneOffset& time_zone)
{
auto formats = format.replace("%s"sv, "{}"sv).split('/');
auto formats = format.replace("%s"sv, "{}"sv, ReplaceMode::FirstOnly).split('/');
VERIFY(formats.size() <= 2);
time_zone.standard_format = time_zone_data.unique_strings.ensure(formats[0]);
@ -422,8 +422,8 @@ static String format_identifier(StringView owner, String identifier)
}
}
identifier = identifier.replace("-"sv, "_"sv, true);
identifier = identifier.replace("/"sv, "_"sv, true);
identifier = identifier.replace("-"sv, "_"sv, ReplaceMode::All);
identifier = identifier.replace("/"sv, "_"sv, ReplaceMode::All);
if (all_of(identifier, is_ascii_digit))
return String::formatted("{}_{}", owner[0], identifier);
@ -690,7 +690,7 @@ Optional<Array<NamedOffset, 2>> get_named_time_zone_offsets(TimeZone time_zone,
auto format_name = [](auto format, auto offset) -> String {
if (offset == 0)
return s_string_list[format].replace("{}"sv, ""sv);
return s_string_list[format].replace("{}"sv, ""sv, ReplaceMode::FirstOnly);
return String::formatted(s_string_list[format], s_string_list[offset]);
};