mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 20:25:07 +00:00
LibJS: Convert length_of_array_like to ThrowCompletionOr
This commit is contained in:
parent
02a88c5063
commit
e90e4ac1e2
11 changed files with 55 additions and 126 deletions
|
@ -59,9 +59,7 @@ String JSONObject::stringify_impl(GlobalObject& global_object, Value value, Valu
|
|||
return {};
|
||||
if (is_array) {
|
||||
auto& replacer_object = replacer.as_object();
|
||||
auto replacer_length = length_of_array_like(global_object, replacer_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto replacer_length = TRY_OR_DISCARD(length_of_array_like(global_object, replacer_object));
|
||||
Vector<String> list;
|
||||
for (size_t i = 0; i < replacer_length; ++i) {
|
||||
auto replacer_value = replacer_object.get(i);
|
||||
|
@ -313,9 +311,7 @@ String JSONObject::serialize_json_array(GlobalObject& global_object, StringifySt
|
|||
state.indent = String::formatted("{}{}", state.indent, state.gap);
|
||||
Vector<String> property_strings;
|
||||
|
||||
auto length = length_of_array_like(global_object, object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto length = TRY_OR_DISCARD(length_of_array_like(global_object, object));
|
||||
|
||||
// Optimization
|
||||
property_strings.ensure_capacity(length);
|
||||
|
@ -499,9 +495,7 @@ Value JSONObject::internalize_json_property(GlobalObject& global_object, Object*
|
|||
};
|
||||
|
||||
if (is_array) {
|
||||
auto length = length_of_array_like(global_object, value_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto length = TRY_OR_DISCARD(length_of_array_like(global_object, value_object));
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
process_property(i);
|
||||
if (vm.exception())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue