Skip to content

Commit

Permalink
src: use Maybe<void> where bool isn't needed
Browse files Browse the repository at this point in the history
PR-URL: #54575
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
targos authored Sep 17, 2024
1 parent 260f1f4 commit d2a4f92
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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) {
Expand All @@ -1138,18 +1138,18 @@ 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
->Set(context,
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().
Expand Down
2 changes: 1 addition & 1 deletion src/node_contextify.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/string_bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down

0 comments on commit d2a4f92

Please sign in to comment.