src: use Maybe<void> where bool isn't needed

PR-URL: https://github.com/nodejs/node/pull/54575
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
Michaël Zasso 2024-09-17 09:53:54 +02:00 committed by GitHub
parent 260f1f4608
commit d2a4f92920
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 14 deletions

View File

@ -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<Array> results = Array::New(env->isolate());
auto add = [&] (bool want_ipv4, bool want_ipv6) -> Maybe<bool> {
auto add = [&](bool want_ipv4, bool want_ipv6) -> Maybe<void> {
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<String> s = OneByteString(env->isolate(), ip);
if (results->Set(env->context(), n, s).IsNothing())
return Nothing<bool>();
return Nothing<void>();
n++;
}
return Just(true);
return JustVoid();
};
switch (order) {

View File

@ -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<Value>& args) {
TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New");
}
Maybe<bool> StoreCodeCacheResult(
Maybe<void> StoreCodeCacheResult(
Environment* env,
Local<Object> target,
ScriptCompiler::CompileOptions compile_options,
@ -1117,7 +1117,7 @@ Maybe<bool> StoreCodeCacheResult(
std::unique_ptr<ScriptCompiler::CachedData> new_cached_data) {
Local<Context> context;
if (!target->GetCreationContext().ToLocal(&context)) {
return Nothing<bool>();
return Nothing<void>();
}
if (compile_options == ScriptCompiler::kConsumeCodeCache) {
if (target
@ -1126,7 +1126,7 @@ Maybe<bool> StoreCodeCacheResult(
env->cached_data_rejected_string(),
Boolean::New(env->isolate(), source.GetCachedData()->rejected))
.IsNothing()) {
return Nothing<bool>();
return Nothing<void>();
}
}
if (produce_cached_data) {
@ -1138,7 +1138,7 @@ Maybe<bool> StoreCodeCacheResult(
new_cached_data->length);
if (target->Set(context, env->cached_data_string(), buf.ToLocalChecked())
.IsNothing()) {
return Nothing<bool>();
return Nothing<void>();
}
}
if (target
@ -1146,10 +1146,10 @@ Maybe<bool> StoreCodeCacheResult(
env->cached_data_produced_string(),
Boolean::New(env->isolate(), cached_data_produced))
.IsNothing()) {
return Nothing<bool>();
return Nothing<void>();
}
}
return Just(true);
return JustVoid();
}
// TODO(RaisinTen): Reuse in ContextifyContext::CompileFunction().

View File

@ -176,7 +176,7 @@ class ContextifyScript final : CPPGC_MIXIN(ContextifyScript) {
v8::TracedReference<v8::UnboundScript> script_;
};
v8::Maybe<bool> StoreCodeCacheResult(
v8::Maybe<void> StoreCodeCacheResult(
Environment* env,
v8::Local<v8::Object> target,
v8::ScriptCompiler::CompileOptions compile_options,

View File

@ -37,19 +37,19 @@ class StringBytes {
public:
class InlineDecoder : public MaybeStackBuffer<char> {
public:
inline v8::Maybe<bool> Decode(Environment* env,
inline v8::Maybe<void> Decode(Environment* env,
v8::Local<v8::String> string,
enum encoding enc) {
size_t storage;
if (!StringBytes::StorageSize(env->isolate(), string, enc).To(&storage))
return v8::Nothing<bool>();
return v8::Nothing<void>();
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(); }