mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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:
1 parent
609d39505d
commit
6cf58d4b26
1 file changed
+2
-2
@@ -634,10 +634,10 @@ bool InitializePrimordials(Local<Context> context) {
|
||||
MaybeLocal<Function> maybe_fn =
|
||||
native_module::NativeModuleEnv::LookupAndCompile(
|
||||
context, *module, ¶meters, 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.
|
||||
|
||||
Reference in new issue
Block a user