Skip to content

Commit 103479a

Browse files
danbevcodebytere
authored andcommitted
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: #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]>
1 parent 3032f0f commit 103479a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/api/environment.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,10 @@ bool InitializePrimordials(Local<Context> context) {
498498
MaybeLocal<Function> maybe_fn =
499499
native_module::NativeModuleEnv::LookupAndCompile(
500500
context, *module, &parameters, nullptr);
501-
if (maybe_fn.IsEmpty()) {
501+
Local<Function> fn;
502+
if (!maybe_fn.ToLocal(&fn)) {
502503
return false;
503504
}
504-
Local<Function> fn = maybe_fn.ToLocalChecked();
505505
MaybeLocal<Value> result =
506506
fn->Call(context, Undefined(isolate), arraysize(arguments), arguments);
507507
// Execution failed during context creation.

0 commit comments

Comments
 (0)