AK: Prefer Optional<StringView> for String::bijective_base_from
Removing one more user of the null StringView state.
This commit is contained in:
parent
08a9646f46
commit
005aa1af62
2 changed files with 5 additions and 4 deletions
|
|
@ -468,11 +468,12 @@ ErrorOr<String> String::repeated(String const& input, size_t count)
|
|||
return result;
|
||||
}
|
||||
|
||||
String String::bijective_base_from(size_t value, Case target_case, unsigned base, StringView map)
|
||||
String String::bijective_base_from(size_t value, Case target_case, unsigned base, Optional<StringView> maybe_map)
|
||||
{
|
||||
value++;
|
||||
if (map.is_null())
|
||||
map = target_case == Case::Upper ? "ABCDEFGHIJKLMNOPQRSTUVWXYZ"sv : "abcdefghijklmnopqrstuvwxyz"sv;
|
||||
if (!maybe_map.has_value())
|
||||
maybe_map = target_case == Case::Upper ? "ABCDEFGHIJKLMNOPQRSTUVWXYZ"sv : "abcdefghijklmnopqrstuvwxyz"sv;
|
||||
auto map = maybe_map.release_value();
|
||||
|
||||
VERIFY(base >= 2 && base <= map.length());
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public:
|
|||
Upper,
|
||||
Lower,
|
||||
};
|
||||
[[nodiscard]] static String bijective_base_from(size_t value, Case, unsigned base = 26, StringView map = {});
|
||||
[[nodiscard]] static String bijective_base_from(size_t value, Case, unsigned base = 26, Optional<StringView> map = {});
|
||||
[[nodiscard]] static String greek_letter_from(size_t value);
|
||||
[[nodiscard]] static String roman_number_from(size_t value, Case);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue