From 6089a04018dc912e11e11f8b0bd7d2118921e6af Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Thu, 16 Feb 2023 11:45:51 -0500 Subject: Prefer emplace back over push_back where emplace_back is more appropriate This also helps a lot with dealing with conversions and data structure creation under the hood. --- absl/flags/parse.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'absl/flags/parse.cc') diff --git a/absl/flags/parse.cc b/absl/flags/parse.cc index fa953f55..368248e3 100644 --- a/absl/flags/parse.cc +++ b/absl/flags/parse.cc @@ -190,7 +190,7 @@ bool ArgsList::ReadFromFlagfile(const std::string& flag_file_name) { // This argument represents fake argv[0], which should be present in all arg // lists. - args_.push_back(""); + args_.emplace_back(""); std::string line; bool success = true; @@ -212,7 +212,7 @@ bool ArgsList::ReadFromFlagfile(const std::string& flag_file_name) { break; } - args_.push_back(std::string(stripped)); + args_.emplace_back(stripped); continue; } @@ -367,7 +367,7 @@ bool ReadFlagsFromEnv(const std::vector& flag_names, // This argument represents fake argv[0], which should be present in all arg // lists. - args.push_back(""); + args.emplace_back(""); for (const auto& flag_name : flag_names) { // Avoid infinite recursion. @@ -680,7 +680,7 @@ std::vector ParseCommandLineImpl(int argc, char* argv[], std::vector flagfile_value; std::vector input_args; - input_args.push_back(ArgsList(argc, argv)); + input_args.emplace_back(argc, argv); std::vector output_args; std::vector positional_args; -- cgit v1.2.3