mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-24 12:02:51 +00:00
LibJS+LibLocale: Propagate OOM from CLDR NumberFormat Vector operations
This commit is contained in:
parent
858126d236
commit
89da8de4ca
Notes:
sideshowbarker
2024-07-17 02:59:43 +09:00
Author: https://github.com/trflynn89
Commit: 89da8de4ca
Pull-request: https://github.com/SerenityOS/serenity/pull/17290
Reviewed-by: https://github.com/linusg ✅
4 changed files with 13 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -798,7 +798,7 @@ namespace Locale {
|
|||
|
||||
generator.append(R"~~~(
|
||||
struct NumberFormatImpl {
|
||||
NumberFormat to_unicode_number_format() const {
|
||||
ErrorOr<NumberFormat> to_unicode_number_format() const {
|
||||
NumberFormat number_format {};
|
||||
|
||||
number_format.magnitude = magnitude;
|
||||
|
@ -808,9 +808,9 @@ struct NumberFormatImpl {
|
|||
number_format.positive_format = decode_string(positive_format);
|
||||
number_format.negative_format = decode_string(negative_format);
|
||||
|
||||
number_format.identifiers.ensure_capacity(identifiers.size());
|
||||
TRY(number_format.identifiers.try_ensure_capacity(identifiers.size()));
|
||||
for (@string_index_type@ identifier : identifiers)
|
||||
number_format.identifiers.append(decode_string(identifier));
|
||||
number_format.identifiers.unchecked_append(decode_string(identifier));
|
||||
|
||||
return number_format;
|
||||
}
|
||||
|
@ -1017,7 +1017,7 @@ ErrorOr<Optional<NumberFormat>> get_standard_number_system_format(StringView loc
|
|||
break;
|
||||
}
|
||||
|
||||
return s_number_formats[format_index].to_unicode_number_format();
|
||||
return TRY(s_number_formats[format_index].to_unicode_number_format());
|
||||
}
|
||||
|
||||
return OptionalNone {};
|
||||
|
@ -1046,10 +1046,10 @@ ErrorOr<Vector<NumberFormat>> get_compact_number_system_formats(StringView local
|
|||
}
|
||||
|
||||
auto number_formats = s_number_format_lists.at(number_format_list_index);
|
||||
formats.ensure_capacity(number_formats.size());
|
||||
TRY(formats.try_ensure_capacity(number_formats.size()));
|
||||
|
||||
for (auto number_format : number_formats)
|
||||
formats.append(s_number_formats[number_format].to_unicode_number_format());
|
||||
formats.unchecked_append(TRY(s_number_formats[number_format].to_unicode_number_format()));
|
||||
}
|
||||
|
||||
return formats;
|
||||
|
@ -1074,7 +1074,7 @@ static Unit const* find_units(StringView locale, StringView unit)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Vector<NumberFormat> get_unit_formats(StringView locale, StringView unit, Style style)
|
||||
ErrorOr<Vector<NumberFormat>> get_unit_formats(StringView locale, StringView unit, Style style)
|
||||
{
|
||||
Vector<NumberFormat> formats;
|
||||
|
||||
|
@ -1096,10 +1096,10 @@ Vector<NumberFormat> get_unit_formats(StringView locale, StringView unit, Style
|
|||
}
|
||||
|
||||
auto number_formats = s_number_format_lists.at(number_format_list_index);
|
||||
formats.ensure_capacity(number_formats.size());
|
||||
TRY(formats.try_ensure_capacity(number_formats.size()));
|
||||
|
||||
for (auto number_format : number_formats)
|
||||
formats.append(s_number_formats[number_format].to_unicode_number_format());
|
||||
formats.unchecked_append(TRY(s_number_formats[number_format].to_unicode_number_format()));
|
||||
}
|
||||
|
||||
return formats;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue