From 8dca89d705739519da33ff2b1a2c755f0137f60f Mon Sep 17 00:00:00 2001 From: Jimmy Thomson Date: Mon, 12 Feb 2018 15:40:46 -0800 Subject: [PATCH] src: changing node_file's usage of v8::Resolver node_file was casting back and forth between v8::Resolver and v8::Promise This is unnecessary; most of the time it just wants the v8::Resolver, converting to the v8::Promise only as a return value. --- src/node_file.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 626e73004ab..52e2d90fc16 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -283,7 +283,8 @@ void FSReqWrap::SetReturnValue(const FunctionCallbackInfo& args) { void FSReqPromise::SetReturnValue(const FunctionCallbackInfo& args) { Local context = env()->context(); args.GetReturnValue().Set( - object()->Get(context, env()->promise_string()).ToLocalChecked()); + object()->Get(context, env()->promise_string()).ToLocalChecked() + .As()->GetPromise()); } void NewFSReqWrap(const FunctionCallbackInfo& args) { @@ -300,7 +301,7 @@ FSReqPromise::FSReqPromise(Environment* env) stats_field_array_(env->isolate(), 14) { auto resolver = Promise::Resolver::New(env->context()).ToLocalChecked(); object()->Set(env->context(), env->promise_string(), - resolver.As()).FromJust(); + resolver).FromJust(); } FSReqPromise::~FSReqPromise() { @@ -315,9 +316,7 @@ void FSReqPromise::Reject(Local reject) { Local value = object()->Get(env()->context(), env()->promise_string()).ToLocalChecked(); - CHECK(value->IsPromise()); - Local promise = value.As(); - Local resolver = promise.As(); + Local resolver = value.As(); resolver->Reject(env()->context(), reject).FromJust(); } @@ -336,7 +335,6 @@ void FSReqPromise::Resolve(Local value) { Local val = object()->Get(env()->context(), env()->promise_string()).ToLocalChecked(); - CHECK(val->IsPromise()); Local resolver = val.As(); resolver->Resolve(env()->context(), value).FromJust(); }