diff options
author | Sam Roberts <vieuxtech@gmail.com> | 2019-04-10 01:21:36 +0300 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2019-04-12 22:33:37 +0300 |
commit | 060d901f87b3d87314f8540eb02f315e2952f581 (patch) | |
tree | 53159171201703bb6d8a4e780c8624a5c6c8cbb5 /src/node_native_module.cc | |
parent | 7b0d8673898e65a368108264c77bccaa3e004028 (diff) |
src: replace FromJust() with Check() when possible
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 <apapirovski@mac.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Diffstat (limited to 'src/node_native_module.cc')
-rw-r--r-- | src/node_native_module.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/node_native_module.cc b/src/node_native_module.cc index 08c0ab16e3d..6462f39ee14 100644 --- a/src/node_native_module.cc +++ b/src/node_native_module.cc @@ -112,7 +112,7 @@ Local<Object> MapToObject(Local<Context> context, Local<Object> out = Object::New(isolate); for (auto const& x : in) { Local<String> 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<Object> 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 |