diff --git a/AK/String.cpp b/AK/String.cpp index 9fa21d78768..d49d70bad69 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -468,11 +468,12 @@ ErrorOr 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 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()); diff --git a/AK/String.h b/AK/String.h index 09e6cf0f0f4..71a34efd7ff 100644 --- a/AK/String.h +++ b/AK/String.h @@ -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 map = {}); [[nodiscard]] static String greek_letter_from(size_t value); [[nodiscard]] static String roman_number_from(size_t value, Case);