Skip to content

Commit b280363

Browse files
danbevaddaleax
authored andcommitted
src: replace IsConstructCall functions with lambda
I noticed that there are three static functions that only check if args is a construct call. This commit suggests replacing them and them with a lambda. PR-URL: #12384 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent a6e4162 commit b280363

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

src/cares_wrap.cc

+7-18
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@ GetAddrInfoReqWrap::GetAddrInfoReqWrap(Environment* env,
115115
}
116116

117117

118-
void NewGetAddrInfoReqWrap(const FunctionCallbackInfo<Value>& args) {
119-
CHECK(args.IsConstructCall());
120-
}
121-
122-
123118
class GetNameInfoReqWrap : public ReqWrap<uv_getnameinfo_t> {
124119
public:
125120
GetNameInfoReqWrap(Environment* env, Local<Object> req_wrap_obj);
@@ -134,16 +129,6 @@ GetNameInfoReqWrap::GetNameInfoReqWrap(Environment* env,
134129
}
135130

136131

137-
void NewGetNameInfoReqWrap(const FunctionCallbackInfo<Value>& args) {
138-
CHECK(args.IsConstructCall());
139-
}
140-
141-
142-
void NewQueryReqWrap(const FunctionCallbackInfo<Value>& args) {
143-
CHECK(args.IsConstructCall());
144-
}
145-
146-
147132
int cmp_ares_tasks(const node_ares_task* a, const node_ares_task* b) {
148133
if (a->sock < b->sock)
149134
return -1;
@@ -1400,24 +1385,28 @@ void Initialize(Local<Object> target,
14001385
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_V4MAPPED"),
14011386
Integer::New(env->isolate(), AI_V4MAPPED));
14021387

1388+
auto is_construct_call_callback =
1389+
[](const FunctionCallbackInfo<Value>& args) {
1390+
CHECK(args.IsConstructCall());
1391+
};
14031392
Local<FunctionTemplate> aiw =
1404-
FunctionTemplate::New(env->isolate(), NewGetAddrInfoReqWrap);
1393+
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
14051394
aiw->InstanceTemplate()->SetInternalFieldCount(1);
14061395
aiw->SetClassName(
14071396
FIXED_ONE_BYTE_STRING(env->isolate(), "GetAddrInfoReqWrap"));
14081397
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "GetAddrInfoReqWrap"),
14091398
aiw->GetFunction());
14101399

14111400
Local<FunctionTemplate> niw =
1412-
FunctionTemplate::New(env->isolate(), NewGetNameInfoReqWrap);
1401+
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
14131402
niw->InstanceTemplate()->SetInternalFieldCount(1);
14141403
niw->SetClassName(
14151404
FIXED_ONE_BYTE_STRING(env->isolate(), "GetNameInfoReqWrap"));
14161405
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "GetNameInfoReqWrap"),
14171406
niw->GetFunction());
14181407

14191408
Local<FunctionTemplate> qrw =
1420-
FunctionTemplate::New(env->isolate(), NewQueryReqWrap);
1409+
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
14211410
qrw->InstanceTemplate()->SetInternalFieldCount(1);
14221411
qrw->SetClassName(
14231412
FIXED_ONE_BYTE_STRING(env->isolate(), "QueryReqWrap"));

0 commit comments

Comments
 (0)