Skip to content

Commit

Permalink
src: use MaybeLocal.ToLocal instead of IsEmpty
Browse files Browse the repository at this point in the history
This commit suggest using MaybeLocal.ToLocal and passing in the
Local<Function> fn.

The motivation for doing this is that the following
MaybeLocal.ToLocalChecked call can then be avoided.

PR-URL: #33312
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
danbev authored and codebytere committed Jun 7, 2020
1 parent 318fcf8 commit 548672d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ MaybeLocal<Value> ExecuteBootstrapper(Environment* env,
MaybeLocal<Function> maybe_fn =
NativeModuleEnv::LookupAndCompile(env->context(), id, parameters, env);

if (maybe_fn.IsEmpty()) {
Local<Function> fn;
if (!maybe_fn.ToLocal(&fn)) {
return MaybeLocal<Value>();
}

Local<Function> fn = maybe_fn.ToLocalChecked();
MaybeLocal<Value> result = fn->Call(env->context(),
Undefined(env->isolate()),
arguments->size(),
Expand Down

0 comments on commit 548672d

Please sign in to comment.