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: #33554
Reviewed-By: Zeyu Yang <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
danbev authored and codebytere committed Jun 18, 2020
1 parent 5438611 commit 20d54f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,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.
Expand Down

0 comments on commit 20d54f6

Please sign in to comment.