Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorDaniel Bevenius <daniel.bevenius@gmail.com>2020-05-25 15:15:43 +0300
committerDaniel Bevenius <daniel.bevenius@gmail.com>2020-05-28 07:14:48 +0300
commit47044a91c6269a395098cf74d4b2a2e70df5c321 (patch)
treea442d37a5a8735ce312ecf824cd0f5105d2db8f1 /src/api
parent27d347b56b1a36d479b4b6b23dca8ea34fecc55c (diff)
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>
Diffstat (limited to 'src/api')
-rw-r--r--src/api/environment.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/api/environment.cc b/src/api/environment.cc
index 99b185798a7..5349657d4c5 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -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.