From 4b1c434b81af709448c11049cee1d9413da3c368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 26 Aug 2024 22:52:25 +0200 Subject: [PATCH] src: use `Maybe` where bool isn't needed --- src/cares_wrap.cc | 7 ++++--- src/node_contextify.cc | 13 +++++++------ src/node_contextify.h | 2 +- src/string_bytes.h | 6 +++--- 4 files changed, 15 insertions(+), 13 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 895f7b9d096166..ccc3ebcaedd182 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -56,6 +56,7 @@ using v8::Integer; using v8::Intercepted; using v8::Isolate; using v8::Just; +using v8::JustVoid; using v8::KeyCollectionMode; using v8::Local; using v8::Maybe; @@ -1059,7 +1060,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, @@ -1068,7 +1069,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 @@ -1077,7 +1078,7 @@ Maybe StoreCodeCacheResult( env->cached_data_rejected_string(), Boolean::New(env->isolate(), source.GetCachedData()->rejected)) .IsNothing()) { - return Nothing(); + return Nothing(); } } if (produce_cached_data) { @@ -1089,7 +1090,7 @@ Maybe StoreCodeCacheResult( new_cached_data->length); if (target->Set(context, env->cached_data_string(), buf.ToLocalChecked()) .IsNothing()) { - return Nothing(); + return Nothing(); } } if (target @@ -1097,10 +1098,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 b9e846f70bad4f..b8c036a8b5ab03 100644 --- a/src/node_contextify.h +++ b/src/node_contextify.h @@ -173,7 +173,7 @@ class ContextifyScript : public BaseObject { v8::Global 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(); }