mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
AK: Prefer Optional<StringView> for String::bijective_base_from
Removing one more user of the null StringView state.
This commit is contained in:
committed by
Shannon Booth
parent
08a9646f46
commit
005aa1af62
Notes:
github-actions[bot]
2026-02-21 11:39:08 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/005aa1af627 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8033
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user