Fix clang-tidy hicpp-use-emplace warnings in args parsing

This commit is contained in:
Matt Hess
2026-02-05 21:26:09 +00:00
parent 9e36f2dfcf
commit bb3fca1310
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -243,10 +243,10 @@ static std::vector<std::vector<std::string>> get_params(int argc, char* argv[])
if ((arg.size() > 2) && (arg[0] == '-') && (arg[1] == '-')) {
// Store the parameter name without the "--" prefix
arg.remove_prefix(2);
args.emplace_back(std::vector<std::string>(1, std::string(arg)));
args.emplace_back().emplace_back(arg);
}
else if (!args.empty()) {
args.back().emplace_back(std::string(arg));
args.back().emplace_back(arg);
}
}
+3 -3
View File
@@ -1073,7 +1073,7 @@ std::vector<std::vector<std::string>> parse_config(const std::string& file_name)
case BEFORE_NAME:
if (is_alpha(c)) {
state = NAME;
args.emplace_back(std::vector<std::string>(1, std::string(1, c)));
args.emplace_back().emplace_back(1, c);
}
else if (c == '#') {
state = COMMENT;
@@ -1103,10 +1103,10 @@ std::vector<std::vector<std::string>> parse_config(const std::string& file_name)
state = VALUE;
quoted = (c == '"');
if (quoted) {
args.back().emplace_back(std::string());
args.back().emplace_back();
}
else {
args.back().emplace_back(std::string(1, c));
args.back().emplace_back(1, c);
}
}
break;