mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibLocale+LibJS: Make locale data APIs infallible
These APIs only perform small allocations, and are only used by LibJS. Callers which could only have failed from these APIs are also made to be infallible here.
This commit is contained in:
parent
a98201f889
commit
cd526813e6
20 changed files with 340 additions and 364 deletions
|
@ -69,7 +69,7 @@ static ThrowCompletionOr<String> apply_options_to_tag(VM& vm, StringView tag, Ob
|
|||
auto canonicalized_tag = MUST_OR_THROW_OOM(canonicalize_unicode_locale_id(vm, *locale_id));
|
||||
|
||||
// 11. Assert: tag matches the unicode_locale_id production.
|
||||
locale_id = TRY_OR_THROW_OOM(vm, ::Locale::parse_unicode_locale_id(canonicalized_tag));
|
||||
locale_id = ::Locale::parse_unicode_locale_id(canonicalized_tag);
|
||||
VERIFY(locale_id.has_value());
|
||||
|
||||
// 12. Let languageId be the substring of tag corresponding to the unicode_language_id production.
|
||||
|
@ -109,7 +109,7 @@ static ThrowCompletionOr<LocaleAndKeys> apply_unicode_extension_to_tag(VM& vm, S
|
|||
{
|
||||
// 1. Assert: Type(tag) is String.
|
||||
// 2. Assert: tag matches the unicode_locale_id production.
|
||||
auto locale_id = TRY_OR_THROW_OOM(vm, ::Locale::parse_unicode_locale_id(tag));
|
||||
auto locale_id = ::Locale::parse_unicode_locale_id(tag);
|
||||
VERIFY(locale_id.has_value());
|
||||
|
||||
Vector<String> attributes;
|
||||
|
@ -198,7 +198,7 @@ static ThrowCompletionOr<LocaleAndKeys> apply_unicode_extension_to_tag(VM& vm, S
|
|||
|
||||
// 7. Let locale be the String value that is tag with any Unicode locale extension sequences removed.
|
||||
locale_id->remove_extension_type<::Locale::LocaleExtension>();
|
||||
auto locale = TRY_OR_THROW_OOM(vm, locale_id->to_string());
|
||||
auto locale = locale_id->to_string();
|
||||
|
||||
// 8. Let newExtension be a Unicode BCP 47 U Extension based on attributes and keywords.
|
||||
::Locale::LocaleExtension new_extension { move(attributes), move(keywords) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue