src: apply clang-tidy rule modernize-use-emplace

PR-URL: https://github.com/nodejs/node/pull/26564
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
gengjiawen 2019-03-10 17:23:56 +08:00 committed by Daniel Bevenius
parent f47adfbda5
commit f091d4e840
6 changed files with 13 additions and 13 deletions

View File

@ -554,10 +554,11 @@ class HttpHandler : public ProtocolHandler {
static int OnMessageComplete(parser_t* parser) { static int OnMessageComplete(parser_t* parser) {
// Event needs to be fired after the parser is done. // Event needs to be fired after the parser is done.
HttpHandler* handler = From(parser); HttpHandler* handler = From(parser);
handler->events_.push_back( handler->events_.emplace_back(handler->path_,
HttpEvent(handler->path_, parser->upgrade, parser->method == HTTP_GET, parser->upgrade,
handler->HeaderValue("Sec-WebSocket-Key"), parser->method == HTTP_GET,
handler->HeaderValue("Host"))); handler->HeaderValue("Sec-WebSocket-Key"),
handler->HeaderValue("Host"));
handler->path_ = ""; handler->path_ = "";
handler->parsing_value_ = false; handler->parsing_value_ = false;
handler->headers_.clear(); handler->headers_.clear();

View File

@ -661,7 +661,7 @@ void AfterScanDirWithTypes(uv_fs_t* req) {
return req_wrap->Reject(error); return req_wrap->Reject(error);
name_v.push_back(filename.ToLocalChecked()); 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<Array> result = Array::New(isolate, 2); Local<Array> result = Array::New(isolate, 2);
@ -1508,7 +1508,7 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
name_v.push_back(filename.ToLocalChecked()); name_v.push_back(filename.ToLocalChecked());
if (with_types) { if (with_types) {
type_v.push_back(Integer::New(isolate, ent.type)); type_v.emplace_back(Integer::New(isolate, ent.type));
} }
} }

View File

@ -387,9 +387,8 @@ Maybe<bool> Message::Serialize(Environment* env,
env->isolate_data()->node_allocator()->UnregisterPointer( env->isolate_data()->node_allocator()->UnregisterPointer(
contents.Data(), contents.ByteLength()); contents.Data(), contents.ByteLength());
array_buffer_contents_.push_back( array_buffer_contents_.emplace_back(MallocedBuffer<char>{
MallocedBuffer<char> { static_cast<char*>(contents.Data()), static_cast<char*>(contents.Data()), contents.ByteLength()});
contents.ByteLength() });
} }
delegate.Finish(); delegate.Finish();

View File

@ -92,7 +92,7 @@ void NativeModuleLoader::ModuleIdsGetter(
ids.reserve(source_.size()); ids.reserve(source_.size());
for (auto const& x : source_) { 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())); info.GetReturnValue().Set(Array::New(isolate, ids.data(), ids.size()));

View File

@ -255,7 +255,7 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
AsyncWrap* w = req_wrap->GetAsyncWrap(); AsyncWrap* w = req_wrap->GetAsyncWrap();
if (w->persistent().IsEmpty()) if (w->persistent().IsEmpty())
continue; continue;
request_v.push_back(w->GetOwner()); request_v.emplace_back(w->GetOwner());
} }
args.GetReturnValue().Set( args.GetReturnValue().Set(
@ -271,7 +271,7 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
for (auto w : *env->handle_wrap_queue()) { for (auto w : *env->handle_wrap_queue()) {
if (!HandleWrap::HasRef(w)) if (!HandleWrap::HasRef(w))
continue; continue;
handle_v.push_back(w->GetOwner()); handle_v.emplace_back(w->GetOwner());
} }
args.GetReturnValue().Set( args.GetReturnValue().Set(
Array::New(env->isolate(), handle_v.data(), handle_v.size())); Array::New(env->isolate(), handle_v.data(), handle_v.size()));

View File

@ -2053,7 +2053,7 @@ void URL::Parse(const char* input,
break; break;
default: default:
if (url->path.size() == 0) if (url->path.size() == 0)
url->path.push_back(""); url->path.emplace_back("");
if (url->path.size() > 0 && ch != kEOL) if (url->path.size() > 0 && ch != kEOL)
AppendOrEscape(&url->path[0], ch, C0_CONTROL_ENCODE_SET); AppendOrEscape(&url->path[0], ch, C0_CONTROL_ENCODE_SET);
} }