From 060d901f87b3d87314f8540eb02f315e2952f581 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Tue, 9 Apr 2019 15:21:36 -0700 Subject: src: replace FromJust() with Check() when possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FromJust() is often used not for its return value, but for its side-effects. In these cases, Check() exists, and is more clear as to the intent. From its comment: To be used, where the actual value of the Maybe is not needed, like Object::Set. See: https://github.com/nodejs/node/pull/26929/files#r269256335 PR-URL: https://github.com/nodejs/node/pull/27162 Reviewed-By: Anatoli Papirovski Reviewed-By: Michaƫl Zasso Reviewed-By: Ben Noordhuis Reviewed-By: Gus Caplan Reviewed-By: Yongsheng Zhang --- src/node_native_module.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/node_native_module.cc') diff --git a/src/node_native_module.cc b/src/node_native_module.cc index 08c0ab16e3..6462f39ee1 100644 --- a/src/node_native_module.cc +++ b/src/node_native_module.cc @@ -112,7 +112,7 @@ Local MapToObject(Local context, Local out = Object::New(isolate); for (auto const& x : in) { Local key = OneByteString(isolate, x.first.c_str(), x.first.size()); - out->Set(context, key, x.second.ToStringChecked(isolate)).FromJust(); + out->Set(context, key, x.second.ToStringChecked(isolate)).Check(); } return out; } @@ -156,12 +156,12 @@ void NativeModuleLoader::GetModuleCategories( ->Set(context, OneByteString(isolate, "cannotBeRequired"), ToJsSet(context, cannot_be_required)) - .FromJust(); + .Check(); result ->Set(context, OneByteString(isolate, "canBeRequired"), ToJsSet(context, can_be_required)) - .FromJust(); + .Check(); info.GetReturnValue().Set(result); } @@ -175,12 +175,12 @@ void NativeModuleLoader::GetCacheUsage( ->Set(env->context(), OneByteString(isolate, "compiledWithCache"), ToJsSet(context, env->native_modules_with_cache)) - .FromJust(); + .Check(); result ->Set(env->context(), OneByteString(isolate, "compiledWithoutCache"), ToJsSet(context, env->native_modules_without_cache)) - .FromJust(); + .Check(); args.GetReturnValue().Set(result); } @@ -418,7 +418,7 @@ void NativeModuleLoader::Initialize(Local target, target, "compileFunction", NativeModuleLoader::CompileFunction); env->SetMethod(target, "getCodeCache", NativeModuleLoader::GetCodeCache); // internalBinding('native_module') should be frozen - target->SetIntegrityLevel(context, IntegrityLevel::kFrozen).FromJust(); + target->SetIntegrityLevel(context, IntegrityLevel::kFrozen).Check(); } } // namespace native_module -- cgit v1.2.3