From d2a4f92920b8257b2f1916440d08057508d54bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 17 Sep 2024 09:53:54 +0200 Subject: [PATCH] src: use `Maybe` where bool isn't needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/54575 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Chengzhong Wu Reviewed-By: Minwoo Jung Reviewed-By: Tobias Nießen --- src/cares_wrap.cc | 7 ++++--- src/node_contextify.cc | 14 +++++++------- src/node_contextify.h | 2 +- src/string_bytes.h | 6 +++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 436b2e3e002d81..c94146511a8cbb 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -66,6 +66,7 @@ using v8::Int32; using v8::Integer; using v8::Isolate; using v8::Just; +using v8::JustVoid; using v8::Local; using v8::Maybe; using v8::Nothing; @@ -1450,7 +1451,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { if (status == 0) { Local results = Array::New(env->isolate()); - auto add = [&] (bool want_ipv4, bool want_ipv6) -> Maybe { + auto add = [&](bool want_ipv4, bool want_ipv6) -> Maybe { for (auto p = res; p != nullptr; p = p->ai_next) { CHECK_EQ(p->ai_socktype, SOCK_STREAM); @@ -1471,10 +1472,10 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { Local s = OneByteString(env->isolate(), ip); if (results->Set(env->context(), n, s).IsNothing()) - return Nothing(); + return Nothing(); n++; } - return Just(true); + return JustVoid(); }; switch (order) { diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 7b4f1f27506adf..fa436da9619989 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -56,7 +56,7 @@ using v8::Int32; using v8::Integer; using v8::Intercepted; using v8::Isolate; -using v8::Just; +using v8::JustVoid; using v8::KeyCollectionMode; using v8::Local; using v8::Maybe; @@ -1108,7 +1108,7 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New"); } -Maybe StoreCodeCacheResult( +Maybe StoreCodeCacheResult( Environment* env, Local target, ScriptCompiler::CompileOptions compile_options, @@ -1117,7 +1117,7 @@ Maybe StoreCodeCacheResult( std::unique_ptr new_cached_data) { Local context; if (!target->GetCreationContext().ToLocal(&context)) { - return Nothing(); + return Nothing(); } if (compile_options == ScriptCompiler::kConsumeCodeCache) { if (target @@ -1126,7 +1126,7 @@ Maybe StoreCodeCacheResult( env->cached_data_rejected_string(), Boolean::New(env->isolate(), source.GetCachedData()->rejected)) .IsNothing()) { - return Nothing(); + return Nothing(); } } if (produce_cached_data) { @@ -1138,7 +1138,7 @@ Maybe StoreCodeCacheResult( new_cached_data->length); if (target->Set(context, env->cached_data_string(), buf.ToLocalChecked()) .IsNothing()) { - return Nothing(); + return Nothing(); } } if (target @@ -1146,10 +1146,10 @@ Maybe StoreCodeCacheResult( env->cached_data_produced_string(), Boolean::New(env->isolate(), cached_data_produced)) .IsNothing()) { - return Nothing(); + return Nothing(); } } - return Just(true); + return JustVoid(); } // TODO(RaisinTen): Reuse in ContextifyContext::CompileFunction(). diff --git a/src/node_contextify.h b/src/node_contextify.h index 294f7197ded23a..d67968406d7b74 100644 --- a/src/node_contextify.h +++ b/src/node_contextify.h @@ -176,7 +176,7 @@ class ContextifyScript final : CPPGC_MIXIN(ContextifyScript) { v8::TracedReference script_; }; -v8::Maybe StoreCodeCacheResult( +v8::Maybe StoreCodeCacheResult( Environment* env, v8::Local target, v8::ScriptCompiler::CompileOptions compile_options, diff --git a/src/string_bytes.h b/src/string_bytes.h index fde5070ffb66a7..53bc003fbda436 100644 --- a/src/string_bytes.h +++ b/src/string_bytes.h @@ -37,19 +37,19 @@ class StringBytes { public: class InlineDecoder : public MaybeStackBuffer { public: - inline v8::Maybe Decode(Environment* env, + inline v8::Maybe Decode(Environment* env, v8::Local string, enum encoding enc) { size_t storage; if (!StringBytes::StorageSize(env->isolate(), string, enc).To(&storage)) - return v8::Nothing(); + return v8::Nothing(); AllocateSufficientStorage(storage); const size_t length = StringBytes::Write(env->isolate(), out(), storage, string, enc); // No zero terminator is included when using this method. SetLength(length); - return v8::Just(true); + return v8::JustVoid(); } inline size_t size() const { return length(); }