summaryrefslogtreecommitdiff
path: root/absl/flags
diff options
context:
space:
mode:
authorGravatar Rose <83477269+AtariDreams@users.noreply.github.com>2023-02-16 11:45:51 -0500
committerGravatar Rose <83477269+AtariDreams@users.noreply.github.com>2023-02-16 11:46:21 -0500
commit6089a04018dc912e11e11f8b0bd7d2118921e6af (patch)
tree20449c1c13d5d96ab3319136007f481d529e31b8 /absl/flags
parent2d4c6872da56fa0d8156b01ab5658348d9c5de4d (diff)
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.
Diffstat (limited to 'absl/flags')
-rw-r--r--absl/flags/internal/usage.cc2
-rw-r--r--absl/flags/parse.cc8
2 files changed, 5 insertions, 5 deletions
diff --git a/absl/flags/internal/usage.cc b/absl/flags/internal/usage.cc
index 5efc7b07..e9481488 100644
--- a/absl/flags/internal/usage.cc
+++ b/absl/flags/internal/usage.cc
@@ -130,7 +130,7 @@ class FlagHelpPrettyPrinter {
for (auto line : absl::StrSplit(str, absl::ByAnyChar("\n\r"))) {
if (!tokens.empty()) {
// Keep line separators in the input string.
- tokens.push_back("\n");
+ tokens.emplace_back("\n");
}
for (auto token :
absl::StrSplit(line, absl::ByAnyChar(" \t"), absl::SkipEmpty())) {
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<std::string>& 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<char*> ParseCommandLineImpl(int argc, char* argv[],
std::vector<std::string> flagfile_value;
std::vector<ArgsList> input_args;
- input_args.push_back(ArgsList(argc, argv));
+ input_args.emplace_back(argc, argv);
std::vector<char*> output_args;
std::vector<char*> positional_args;