From ee45b78b7f382f8e63ba66386a2524a0ca6722de Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 18 May 2020 13:18:52 +0200 Subject: [PATCH] src: use MaybeLocal.ToLocal instead of IsEmpty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit suggest using MaybeLocal.ToLocal and passing in the Local fun. The motivation for doing this is that the following MaybeLocal.ToLocalChecked call can then be avoided. PR-URL: https://github.com/nodejs/node/pull/33457 Reviewed-By: Zeyu Yang Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: David Carlier Reviewed-By: Juan José Arboleda --- src/node_native_module.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_native_module.cc b/src/node_native_module.cc index c3a77198090f86..a57355418bea06 100644 --- a/src/node_native_module.cc +++ b/src/node_native_module.cc @@ -292,14 +292,14 @@ MaybeLocal NativeModuleLoader::LookupAndCompile( // This could fail when there are early errors in the native modules, // e.g. the syntax errors - if (maybe_fun.IsEmpty()) { + Local fun; + if (!maybe_fun.ToLocal(&fun)) { // In the case of early errors, v8 is already capable of // decorating the stack for us - note that we use CompileFunctionInContext // so there is no need to worry about wrappers. return MaybeLocal(); } - Local fun = maybe_fun.ToLocalChecked(); // XXX(joyeecheung): this bookkeeping is not exactly accurate because // it only starts after the Environment is created, so the per_context.js // will never be in any of these two sets, but the two sets are only for