src: apply clang-tidy rule modernize-use-emplace · nodejs/node@f091d4e (original) (raw)

6 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -554,10 +554,11 @@ class HttpHandler : public ProtocolHandler {
554 554 static int OnMessageComplete(parser_t* parser) {
555 555 // Event needs to be fired after the parser is done.
556 556 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"));
561 562 handler->path_ = "";
562 563 handler->parsing_value_ = false;
563 564 handler->headers_.clear();
Original file line number Diff line number Diff line change
@@ -661,7 +661,7 @@ void AfterScanDirWithTypes(uv_fs_t* req) {
661 661 return req_wrap->Reject(error);
662 662
663 663 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));
665 665 }
666 666
667 667 Local result = Array::New(isolate, 2);
@@ -1508,7 +1508,7 @@ static void ReadDir(const FunctionCallbackInfo& args) {
1508 1508 name_v.push_back(filename.ToLocalChecked());
1509 1509
1510 1510 if (with_types) {
1511 - type_v.push_back(Integer::New(isolate, ent.type));
1511 + type_v.emplace_back(Integer::New(isolate, ent.type));
1512 1512 }
1513 1513 }
1514 1514
Original file line number Diff line number Diff line change
@@ -387,9 +387,8 @@ Maybe Message::Serialize(Environment* env,
387 387 env->isolate_data()->node_allocator()->UnregisterPointer(
388 388 contents.Data(), contents.ByteLength());
389 389
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()});
393 392 }
394 393
395 394 delegate.Finish();
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ void NativeModuleLoader::ModuleIdsGetter(
92 92 ids.reserve(source_.size());
93 93
94 94 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()));
96 96 }
97 97
98 98 info.GetReturnValue().Set(Array::New(isolate, ids.data(), ids.size()));
Original file line number Diff line number Diff line change
@@ -255,7 +255,7 @@ static void GetActiveRequests(const FunctionCallbackInfo& args) {
255 255 AsyncWrap* w = req_wrap->GetAsyncWrap();
256 256 if (w->persistent().IsEmpty())
257 257 continue;
258 - request_v.push_back(w->GetOwner());
258 + request_v.emplace_back(w->GetOwner());
259 259 }
260 260
261 261 args.GetReturnValue().Set(
@@ -271,7 +271,7 @@ void GetActiveHandles(const FunctionCallbackInfo& args) {
271 271 for (auto w : *env->handle_wrap_queue()) {
272 272 if (!HandleWrap::HasRef(w))
273 273 continue;
274 - handle_v.push_back(w->GetOwner());
274 + handle_v.emplace_back(w->GetOwner());
275 275 }
276 276 args.GetReturnValue().Set(
277 277 Array::New(env->isolate(), handle_v.data(), handle_v.size()));
Original file line number Diff line number Diff line change
@@ -2053,7 +2053,7 @@ void URL::Parse(const char* input,
2053 2053 break;
2054 2054 default:
2055 2055 if (url->path.size() == 0)
2056 - url->path.push_back("");
2056 + url->path.emplace_back("");
2057 2057 if (url->path.size() > 0 && ch != kEOL)
2058 2058 AppendOrEscape(&url->path[0], ch, C0_CONTROL_ENCODE_SET);
2059 2059 }