AK: Prefer Optional<StringView> for String::bijective_base_from

Removing one more user of the null StringView state.
This commit is contained in:
Shannon Booth
2026-02-19 13:25:00 +01:00
committed by Shannon Booth
parent 08a9646f46
commit 005aa1af62
Notes: github-actions[bot] 2026-02-21 11:39:08 +00:00
2 changed files with 5 additions and 4 deletions

View File

@@ -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());

View File

@@ -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);