Skip to content

Commit

Permalink
src: refactor src/node_util.cc
Browse files Browse the repository at this point in the history
Use static sized data structure
  • Loading branch information
kt3k committed Nov 28, 2018
1 parent 11230d2 commit 3729328
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/node_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ static void GetPromiseDetails(const FunctionCallbackInfo<Value>& args) {
Local<Promise> promise = args[0].As<Promise>();

int state = promise->State();
std::vector<Local<Value>> values(2);
values.push_back(Integer::New(isolate, state));
Local<Value> values[2] = { Integer::New(isolate, state) };
size_t number_of_values = 1;
if (state != Promise::PromiseState::kPending)
values.push_back(promise->Result());

Local<Array> ret = Array::New(
isolate, values.data(), values.size());
values[number_of_values++] = promise->Result();
Local<Array> ret = Array::New(isolate, values, number_of_values);
args.GetReturnValue().Set(ret);
}

Expand Down

0 comments on commit 3729328

Please sign in to comment.