diff --git a/src/node_util.cc b/src/node_util.cc index 1a08c0e255f8d3..496b6cbbcb1573 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -64,13 +64,13 @@ static void GetPromiseDetails(const FunctionCallbackInfo& args) { auto isolate = args.GetIsolate(); Local promise = args[0].As(); - Local ret = Array::New(isolate, 2); int state = promise->State(); - ret->Set(env->context(), 0, Integer::New(isolate, state)).FromJust(); + Local values[2] = { Integer::New(isolate, state) }; + size_t number_of_values = 1; if (state != Promise::PromiseState::kPending) - ret->Set(env->context(), 1, promise->Result()).FromJust(); - + values[number_of_values++] = promise->Result(); + Local ret = Array::New(isolate, values, number_of_values); args.GetReturnValue().Set(ret); } @@ -82,11 +82,13 @@ static void GetProxyDetails(const FunctionCallbackInfo& args) { Local proxy = args[0].As(); - Local ret = Array::New(args.GetIsolate(), 2); - ret->Set(env->context(), 0, proxy->GetTarget()).FromJust(); - ret->Set(env->context(), 1, proxy->GetHandler()).FromJust(); + Local ret[] = { + proxy->GetTarget(), + proxy->GetHandler() + }; - args.GetReturnValue().Set(ret); + args.GetReturnValue().Set( + Array::New(args.GetIsolate(), ret, arraysize(ret))); } static void PreviewEntries(const FunctionCallbackInfo& args) { @@ -101,11 +103,13 @@ static void PreviewEntries(const FunctionCallbackInfo& args) { // Fast path for WeakMap, WeakSet and Set iterators. if (args.Length() == 1) return args.GetReturnValue().Set(entries); - Local ret = Array::New(env->isolate(), 2); - ret->Set(env->context(), 0, entries).FromJust(); - ret->Set(env->context(), 1, Boolean::New(env->isolate(), is_key_value)) - .FromJust(); - return args.GetReturnValue().Set(ret); + + Local ret[] = { + entries, + Boolean::New(env->isolate(), is_key_value) + }; + return args.GetReturnValue().Set( + Array::New(env->isolate(), ret, arraysize(ret))); } // Side effect-free stringification that will never throw exceptions.