mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00:00
LibJS: Propagate OOM from remaining Intl Vector operations
This commit is contained in:
parent
9af525bbb0
commit
858126d236
Notes:
sideshowbarker
2024-07-17 14:33:07 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/858126d236 Pull-request: https://github.com/SerenityOS/serenity/pull/17290 Reviewed-by: https://github.com/linusg ✅
2 changed files with 7 additions and 6 deletions
|
@ -70,16 +70,17 @@ JS_DEFINE_NATIVE_FUNCTION(Intl::get_canonical_locales)
|
|||
auto locale_list = TRY(canonicalize_locale_list(vm, locales));
|
||||
|
||||
MarkedVector<Value> marked_locale_list { vm.heap() };
|
||||
marked_locale_list.ensure_capacity(locale_list.size());
|
||||
TRY_OR_THROW_OOM(vm, marked_locale_list.try_ensure_capacity(locale_list.size()));
|
||||
|
||||
for (auto& locale : locale_list)
|
||||
marked_locale_list.append(PrimitiveString::create(vm, move(locale)));
|
||||
marked_locale_list.unchecked_append(PrimitiveString::create(vm, move(locale)));
|
||||
|
||||
// 2. Return CreateArrayFromList(ll).
|
||||
return Array::create_from(realm, marked_locale_list);
|
||||
}
|
||||
|
||||
// 1.4.4 AvailableCanonicalTimeZones (), https://tc39.es/proposal-intl-enumeration/#sec-availablecanonicaltimezones
|
||||
static Vector<StringView> available_canonical_time_zones()
|
||||
static ThrowCompletionOr<Vector<StringView>> available_canonical_time_zones(VM& vm)
|
||||
{
|
||||
// 1. Let names be a List of all supported Zone and Link names in the IANA Time Zone Database.
|
||||
auto names = TimeZone::all_time_zones();
|
||||
|
@ -96,7 +97,7 @@ static Vector<StringView> available_canonical_time_zones()
|
|||
// c. If result does not contain an element equal to canonical, then
|
||||
if (!result.contains_slow(canonical)) {
|
||||
// i. Append canonical to the end of result.
|
||||
result.append(canonical);
|
||||
TRY_OR_THROW_OOM(vm, result.try_append(canonical));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +141,7 @@ JS_DEFINE_NATIVE_FUNCTION(Intl::supported_values_of)
|
|||
// 6. Else if key is "timeZone", then
|
||||
else if (key == "timeZone"sv) {
|
||||
// a. Let list be ! AvailableCanonicalTimeZones( ).
|
||||
static auto time_zones = available_canonical_time_zones();
|
||||
static auto time_zones = MUST_OR_THROW_OOM(available_canonical_time_zones(vm));
|
||||
list = time_zones.span();
|
||||
}
|
||||
// 7. Else if key is "unit", then
|
||||
|
|
|
@ -188,7 +188,7 @@ static ThrowCompletionOr<LocaleAndKeys> apply_unicode_extension_to_tag(VM& vm, S
|
|||
// iv. Else,
|
||||
else {
|
||||
// 1. Append the Record { [[Key]]: key, [[Value]]: value } to keywords.
|
||||
keywords.append({ TRY_OR_THROW_OOM(vm, String::from_utf8(key)), *value });
|
||||
TRY_OR_THROW_OOM(vm, keywords.try_append({ TRY_OR_THROW_OOM(vm, String::from_utf8(key)), *value }));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue