mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibJS: Propagate OOM from PatternPartitionWithSource factory
This commit is contained in:
parent
e86eafe65e
commit
ea13f3e285
Notes:
sideshowbarker
2024-07-17 01:21:02 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/ea13f3e285 Pull-request: https://github.com/SerenityOS/serenity/pull/17290 Reviewed-by: https://github.com/linusg ✅
3 changed files with 9 additions and 7 deletions
|
@ -11,9 +11,11 @@
|
|||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Intl/DisplayNames.h>
|
||||
#include <LibJS/Runtime/Intl/SingleUnitIdentifiers.h>
|
||||
#include <LibJS/Runtime/Temporal/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
#include <LibLocale/Forward.h>
|
||||
|
||||
|
@ -54,16 +56,16 @@ struct PatternPartition {
|
|||
};
|
||||
|
||||
struct PatternPartitionWithSource : public PatternPartition {
|
||||
static Vector<PatternPartitionWithSource> create_from_parent_list(Vector<PatternPartition> partitions)
|
||||
static ThrowCompletionOr<Vector<PatternPartitionWithSource>> create_from_parent_list(VM& vm, Vector<PatternPartition> partitions)
|
||||
{
|
||||
Vector<PatternPartitionWithSource> result;
|
||||
result.ensure_capacity(partitions.size());
|
||||
TRY_OR_THROW_OOM(vm, result.try_ensure_capacity(partitions.size()));
|
||||
|
||||
for (auto& partition : partitions) {
|
||||
PatternPartitionWithSource partition_with_source {};
|
||||
partition_with_source.type = partition.type;
|
||||
partition_with_source.value = move(partition.value);
|
||||
result.append(move(partition_with_source));
|
||||
result.unchecked_append(move(partition_with_source));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -1079,7 +1079,7 @@ ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_date_time_range_
|
|||
|
||||
// c. Let result be ? FormatDateTimePattern(dateTimeFormat, patternParts, x, undefined).
|
||||
auto raw_result = TRY(format_date_time_pattern(vm, date_time_format, move(pattern_parts), start, nullptr));
|
||||
auto result = PatternPartitionWithSource::create_from_parent_list(move(raw_result));
|
||||
auto result = MUST_OR_THROW_OOM(PatternPartitionWithSource::create_from_parent_list(vm, move(raw_result)));
|
||||
|
||||
// d. For each Record { [[Type]], [[Value]] } r in result, do
|
||||
for (auto& part : result) {
|
||||
|
@ -1136,7 +1136,7 @@ ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_date_time_range_
|
|||
|
||||
// f. Let partResult be ? FormatDateTimePattern(dateTimeFormat, patternParts, z, rangePattern).
|
||||
auto raw_part_result = TRY(format_date_time_pattern(vm, date_time_format, move(pattern_parts), time, &range_pattern.value()));
|
||||
auto part_result = PatternPartitionWithSource::create_from_parent_list(move(raw_part_result));
|
||||
auto part_result = MUST_OR_THROW_OOM(PatternPartitionWithSource::create_from_parent_list(vm, move(raw_part_result)));
|
||||
|
||||
// g. For each Record { [[Type]], [[Value]] } r in partResult, do
|
||||
for (auto& part : part_result) {
|
||||
|
|
|
@ -1801,11 +1801,11 @@ ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_number_range_pat
|
|||
|
||||
// 3. Let xResult be ? PartitionNumberPattern(numberFormat, x).
|
||||
auto raw_start_result = TRY(partition_number_pattern(vm, number_format, move(start)));
|
||||
auto start_result = PatternPartitionWithSource::create_from_parent_list(move(raw_start_result));
|
||||
auto start_result = MUST_OR_THROW_OOM(PatternPartitionWithSource::create_from_parent_list(vm, move(raw_start_result)));
|
||||
|
||||
// 4. Let yResult be ? PartitionNumberPattern(numberFormat, y).
|
||||
auto raw_end_result = TRY(partition_number_pattern(vm, number_format, move(end)));
|
||||
auto end_result = PatternPartitionWithSource::create_from_parent_list(move(raw_end_result));
|
||||
auto end_result = MUST_OR_THROW_OOM(PatternPartitionWithSource::create_from_parent_list(vm, move(raw_end_result)));
|
||||
|
||||
// 5. If xResult is equal to yResult, then
|
||||
if (start_result == end_result) {
|
||||
|
|
Loading…
Reference in a new issue