Skip to content

Commit d2a4f92

Browse files
authored
src: use Maybe<void> where bool isn't needed
PR-URL: #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>
1 parent 260f1f4 commit d2a4f92

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/cares_wrap.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ using v8::Int32;
6666
using v8::Integer;
6767
using v8::Isolate;
6868
using v8::Just;
69+
using v8::JustVoid;
6970
using v8::Local;
7071
using v8::Maybe;
7172
using v8::Nothing;
@@ -1450,7 +1451,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
14501451
if (status == 0) {
14511452
Local<Array> results = Array::New(env->isolate());
14521453

1453-
auto add = [&] (bool want_ipv4, bool want_ipv6) -> Maybe<bool> {
1454+
auto add = [&](bool want_ipv4, bool want_ipv6) -> Maybe<void> {
14541455
for (auto p = res; p != nullptr; p = p->ai_next) {
14551456
CHECK_EQ(p->ai_socktype, SOCK_STREAM);
14561457

@@ -1471,10 +1472,10 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
14711472

14721473
Local<String> s = OneByteString(env->isolate(), ip);
14731474
if (results->Set(env->context(), n, s).IsNothing())
1474-
return Nothing<bool>();
1475+
return Nothing<void>();
14751476
n++;
14761477
}
1477-
return Just(true);
1478+
return JustVoid();
14781479
};
14791480

14801481
switch (order) {

src/node_contextify.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ using v8::Int32;
5656
using v8::Integer;
5757
using v8::Intercepted;
5858
using v8::Isolate;
59-
using v8::Just;
59+
using v8::JustVoid;
6060
using v8::KeyCollectionMode;
6161
using v8::Local;
6262
using v8::Maybe;
@@ -1108,7 +1108,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
11081108
TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New");
11091109
}
11101110

1111-
Maybe<bool> StoreCodeCacheResult(
1111+
Maybe<void> StoreCodeCacheResult(
11121112
Environment* env,
11131113
Local<Object> target,
11141114
ScriptCompiler::CompileOptions compile_options,
@@ -1117,7 +1117,7 @@ Maybe<bool> StoreCodeCacheResult(
11171117
std::unique_ptr<ScriptCompiler::CachedData> new_cached_data) {
11181118
Local<Context> context;
11191119
if (!target->GetCreationContext().ToLocal(&context)) {
1120-
return Nothing<bool>();
1120+
return Nothing<void>();
11211121
}
11221122
if (compile_options == ScriptCompiler::kConsumeCodeCache) {
11231123
if (target
@@ -1126,7 +1126,7 @@ Maybe<bool> StoreCodeCacheResult(
11261126
env->cached_data_rejected_string(),
11271127
Boolean::New(env->isolate(), source.GetCachedData()->rejected))
11281128
.IsNothing()) {
1129-
return Nothing<bool>();
1129+
return Nothing<void>();
11301130
}
11311131
}
11321132
if (produce_cached_data) {
@@ -1138,18 +1138,18 @@ Maybe<bool> StoreCodeCacheResult(
11381138
new_cached_data->length);
11391139
if (target->Set(context, env->cached_data_string(), buf.ToLocalChecked())
11401140
.IsNothing()) {
1141-
return Nothing<bool>();
1141+
return Nothing<void>();
11421142
}
11431143
}
11441144
if (target
11451145
->Set(context,
11461146
env->cached_data_produced_string(),
11471147
Boolean::New(env->isolate(), cached_data_produced))
11481148
.IsNothing()) {
1149-
return Nothing<bool>();
1149+
return Nothing<void>();
11501150
}
11511151
}
1152-
return Just(true);
1152+
return JustVoid();
11531153
}
11541154

11551155
// TODO(RaisinTen): Reuse in ContextifyContext::CompileFunction().

src/node_contextify.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class ContextifyScript final : CPPGC_MIXIN(ContextifyScript) {
176176
v8::TracedReference<v8::UnboundScript> script_;
177177
};
178178

179-
v8::Maybe<bool> StoreCodeCacheResult(
179+
v8::Maybe<void> StoreCodeCacheResult(
180180
Environment* env,
181181
v8::Local<v8::Object> target,
182182
v8::ScriptCompiler::CompileOptions compile_options,

src/string_bytes.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ class StringBytes {
3737
public:
3838
class InlineDecoder : public MaybeStackBuffer<char> {
3939
public:
40-
inline v8::Maybe<bool> Decode(Environment* env,
40+
inline v8::Maybe<void> Decode(Environment* env,
4141
v8::Local<v8::String> string,
4242
enum encoding enc) {
4343
size_t storage;
4444
if (!StringBytes::StorageSize(env->isolate(), string, enc).To(&storage))
45-
return v8::Nothing<bool>();
45+
return v8::Nothing<void>();
4646
AllocateSufficientStorage(storage);
4747
const size_t length =
4848
StringBytes::Write(env->isolate(), out(), storage, string, enc);
4949

5050
// No zero terminator is included when using this method.
5151
SetLength(length);
52-
return v8::Just(true);
52+
return v8::JustVoid();
5353
}
5454

5555
inline size_t size() const { return length(); }

0 commit comments

Comments
 (0)