From f5710486bbc6c983f910afcb958a3d53d5296c8a Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Sun, 10 Mar 2019 17:23:56 +0800 Subject: [PATCH] src: apply clang-tidy rule modernize-use-emplace --- src/inspector_socket.cc | 9 +++++---- src/node_file.cc | 4 ++-- src/node_messaging.cc | 5 ++--- src/node_native_module.cc | 2 +- src/node_process_methods.cc | 4 ++-- src/node_url.cc | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/inspector_socket.cc b/src/inspector_socket.cc index 139a7352ea7667..1af9f18a54a659 100644 --- a/src/inspector_socket.cc +++ b/src/inspector_socket.cc @@ -554,10 +554,11 @@ class HttpHandler : public ProtocolHandler { static int OnMessageComplete(parser_t* parser) { // Event needs to be fired after the parser is done. HttpHandler* handler = From(parser); - handler->events_.push_back( - HttpEvent(handler->path_, parser->upgrade, parser->method == HTTP_GET, - handler->HeaderValue("Sec-WebSocket-Key"), - handler->HeaderValue("Host"))); + handler->events_.emplace_back(handler->path_, + parser->upgrade, + parser->method == HTTP_GET, + handler->HeaderValue("Sec-WebSocket-Key"), + handler->HeaderValue("Host")); handler->path_ = ""; handler->parsing_value_ = false; handler->headers_.clear(); diff --git a/src/node_file.cc b/src/node_file.cc index 137cac72793338..732e2dddcca583 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -658,7 +658,7 @@ void AfterScanDirWithTypes(uv_fs_t* req) { return req_wrap->Reject(error); name_v.push_back(filename.ToLocalChecked()); - type_v.push_back(Integer::New(isolate, ent.type)); + type_v.emplace_back(Integer::New(isolate, ent.type)); } Local result = Array::New(isolate, 2); @@ -1505,7 +1505,7 @@ static void ReadDir(const FunctionCallbackInfo& args) { name_v.push_back(filename.ToLocalChecked()); if (with_types) { - type_v.push_back(Integer::New(isolate, ent.type)); + type_v.emplace_back(Integer::New(isolate, ent.type)); } } diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 21e0191c12a425..e0b8da9fbc9ac1 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -375,9 +375,8 @@ Maybe Message::Serialize(Environment* env, env->isolate_data()->node_allocator()->UnregisterPointer( contents.Data(), contents.ByteLength()); - array_buffer_contents_.push_back( - MallocedBuffer { static_cast(contents.Data()), - contents.ByteLength() }); + array_buffer_contents_.emplace_back(MallocedBuffer{ + static_cast(contents.Data()), contents.ByteLength()}); } delegate.Finish(); diff --git a/src/node_native_module.cc b/src/node_native_module.cc index 33df8c0aa8e590..41f1588c4da792 100644 --- a/src/node_native_module.cc +++ b/src/node_native_module.cc @@ -92,7 +92,7 @@ void NativeModuleLoader::ModuleIdsGetter( ids.reserve(source_.size()); for (auto const& x : source_) { - ids.push_back(OneByteString(isolate, x.first.c_str(), x.first.size())); + ids.emplace_back(OneByteString(isolate, x.first.c_str(), x.first.size())); } info.GetReturnValue().Set(Array::New(isolate, ids.data(), ids.size())); diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index b46735bc791dd4..62ff5a62fc4493 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -256,7 +256,7 @@ static void GetActiveRequests(const FunctionCallbackInfo& args) { AsyncWrap* w = req_wrap->GetAsyncWrap(); if (w->persistent().IsEmpty()) continue; - request_v.push_back(w->GetOwner()); + request_v.emplace_back(w->GetOwner()); } args.GetReturnValue().Set( @@ -272,7 +272,7 @@ void GetActiveHandles(const FunctionCallbackInfo& args) { for (auto w : *env->handle_wrap_queue()) { if (!HandleWrap::HasRef(w)) continue; - handle_v.push_back(w->GetOwner()); + handle_v.emplace_back(w->GetOwner()); } args.GetReturnValue().Set( Array::New(env->isolate(), handle_v.data(), handle_v.size())); diff --git a/src/node_url.cc b/src/node_url.cc index 2070b713ac3d60..35d32d69b7fab4 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -2053,7 +2053,7 @@ void URL::Parse(const char* input, break; default: if (url->path.size() == 0) - url->path.push_back(""); + url->path.emplace_back(""); if (url->path.size() > 0 && ch != kEOL) AppendOrEscape(&url->path[0], ch, C0_CONTROL_ENCODE_SET); }