src: use MaybeLocal.ToLocal instead of IsEmpty

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: https://github.com/nodejs/node/pull/33554
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Daniel Bevenius authored and Shelley Vohr committed 2020-07-08 13:39:31 -07:00
1 parent 3032f0f38d
commit 103479a0c5
1 file changed
+2 -2
+2 -2
View File
@@ -498,10 +498,10 @@ bool InitializePrimordials(Local<Context> context) {
MaybeLocal<Function> maybe_fn =
native_module::NativeModuleEnv::LookupAndCompile(
context, *module, &parameters, nullptr);
if (maybe_fn.IsEmpty()) {
Local<Function> fn;
if (!maybe_fn.ToLocal(&fn)) {
return false;
}
Local<Function> fn = maybe_fn.ToLocalChecked();
MaybeLocal<Value> result =
fn->Call(context, Undefined(isolate), arraysize(arguments), arguments);
// Execution failed during context creation.