Skip to content
Permalink
Browse files
src: use MaybeLocal.ToLocal instead of IsEmpty
This commit suggest using MaybeLocal.ToLocal and passing in the
Local<Function> fun.

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

PR-URL: #33457
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
  • Loading branch information
danbev authored and codebytere committed Jun 18, 2020
1 parent b675ea0 commit ee45b78b7f382f8e63ba66386a2524a0ca6722de
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/node_native_module.cc
@@ -292,14 +292,14 @@ MaybeLocal<Function> NativeModuleLoader::LookupAndCompile(

// This could fail when there are early errors in the native modules,
// e.g. the syntax errors
if (maybe_fun.IsEmpty()) {
Local<Function> fun;
if (!maybe_fun.ToLocal(&fun)) {
// In the case of early errors, v8 is already capable of
// decorating the stack for us - note that we use CompileFunctionInContext
// so there is no need to worry about wrappers.
return MaybeLocal<Function>();
}

Local<Function> fun = maybe_fun.ToLocalChecked();
// XXX(joyeecheung): this bookkeeping is not exactly accurate because
// it only starts after the Environment is created, so the per_context.js
// will never be in any of these two sets, but the two sets are only for

0 comments on commit ee45b78

Please sign in to comment.