Skip to content

Commit a522c0e

Browse files
danbevcodebytere
authored andcommitted
src: use MaybeLocal.ToLocal instead of IsEmpty
This commit suggest using MaybeLocal.ToLocal and passing in the Local<Function> fun. The motivation for doing this is that the following MaybeLocal.ToLocalChecked call can then be avoided. PR-URL: #33457 Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
1 parent 5fb1cc8 commit a522c0e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/node_native_module.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,14 @@ MaybeLocal<Function> NativeModuleLoader::LookupAndCompile(
284284

285285
// This could fail when there are early errors in the native modules,
286286
// e.g. the syntax errors
287-
if (maybe_fun.IsEmpty()) {
287+
Local<Function> fun;
288+
if (!maybe_fun.ToLocal(&fun)) {
288289
// In the case of early errors, v8 is already capable of
289290
// decorating the stack for us - note that we use CompileFunctionInContext
290291
// so there is no need to worry about wrappers.
291292
return MaybeLocal<Function>();
292293
}
293294

294-
Local<Function> fun = maybe_fun.ToLocalChecked();
295295
// XXX(joyeecheung): this bookkeeping is not exactly accurate because
296296
// it only starts after the Environment is created, so the per_context.js
297297
// will never be in any of these two sets, but the two sets are only for

0 commit comments

Comments
 (0)