Skip to content

Commit f091d4e

Browse files
gengjiawendanbev
authored andcommitted
src: apply clang-tidy rule modernize-use-emplace
PR-URL: #26564 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent f47adfb commit f091d4e

6 files changed

+13
-13
lines changed

src/inspector_socket.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -554,10 +554,11 @@ class HttpHandler : public ProtocolHandler {
554554
static int OnMessageComplete(parser_t* parser) {
555555
// Event needs to be fired after the parser is done.
556556
HttpHandler* handler = From(parser);
557-
handler->events_.push_back(
558-
HttpEvent(handler->path_, parser->upgrade, parser->method == HTTP_GET,
559-
handler->HeaderValue("Sec-WebSocket-Key"),
560-
handler->HeaderValue("Host")));
557+
handler->events_.emplace_back(handler->path_,
558+
parser->upgrade,
559+
parser->method == HTTP_GET,
560+
handler->HeaderValue("Sec-WebSocket-Key"),
561+
handler->HeaderValue("Host"));
561562
handler->path_ = "";
562563
handler->parsing_value_ = false;
563564
handler->headers_.clear();

src/node_file.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ void AfterScanDirWithTypes(uv_fs_t* req) {
661661
return req_wrap->Reject(error);
662662

663663
name_v.push_back(filename.ToLocalChecked());
664-
type_v.push_back(Integer::New(isolate, ent.type));
664+
type_v.emplace_back(Integer::New(isolate, ent.type));
665665
}
666666

667667
Local<Array> result = Array::New(isolate, 2);
@@ -1508,7 +1508,7 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
15081508
name_v.push_back(filename.ToLocalChecked());
15091509

15101510
if (with_types) {
1511-
type_v.push_back(Integer::New(isolate, ent.type));
1511+
type_v.emplace_back(Integer::New(isolate, ent.type));
15121512
}
15131513
}
15141514

src/node_messaging.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,8 @@ Maybe<bool> Message::Serialize(Environment* env,
387387
env->isolate_data()->node_allocator()->UnregisterPointer(
388388
contents.Data(), contents.ByteLength());
389389

390-
array_buffer_contents_.push_back(
391-
MallocedBuffer<char> { static_cast<char*>(contents.Data()),
392-
contents.ByteLength() });
390+
array_buffer_contents_.emplace_back(MallocedBuffer<char>{
391+
static_cast<char*>(contents.Data()), contents.ByteLength()});
393392
}
394393

395394
delegate.Finish();

src/node_native_module.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void NativeModuleLoader::ModuleIdsGetter(
9292
ids.reserve(source_.size());
9393

9494
for (auto const& x : source_) {
95-
ids.push_back(OneByteString(isolate, x.first.c_str(), x.first.size()));
95+
ids.emplace_back(OneByteString(isolate, x.first.c_str(), x.first.size()));
9696
}
9797

9898
info.GetReturnValue().Set(Array::New(isolate, ids.data(), ids.size()));

src/node_process_methods.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
255255
AsyncWrap* w = req_wrap->GetAsyncWrap();
256256
if (w->persistent().IsEmpty())
257257
continue;
258-
request_v.push_back(w->GetOwner());
258+
request_v.emplace_back(w->GetOwner());
259259
}
260260

261261
args.GetReturnValue().Set(
@@ -271,7 +271,7 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
271271
for (auto w : *env->handle_wrap_queue()) {
272272
if (!HandleWrap::HasRef(w))
273273
continue;
274-
handle_v.push_back(w->GetOwner());
274+
handle_v.emplace_back(w->GetOwner());
275275
}
276276
args.GetReturnValue().Set(
277277
Array::New(env->isolate(), handle_v.data(), handle_v.size()));

src/node_url.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,7 @@ void URL::Parse(const char* input,
20532053
break;
20542054
default:
20552055
if (url->path.size() == 0)
2056-
url->path.push_back("");
2056+
url->path.emplace_back("");
20572057
if (url->path.size() > 0 && ch != kEOL)
20582058
AppendOrEscape(&url->path[0], ch, C0_CONTROL_ENCODE_SET);
20592059
}

0 commit comments

Comments
 (0)