summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSascha Roloff <sascha.roloff@huawei.com>2023-02-15 17:47:23 +0100
committerSascha Roloff <sascha.roloff@huawei.com>2023-02-15 18:02:32 +0100
commitd57a7bf8964de96456bd0f9a886c9f2cfa326e60 (patch)
tree698002076180bb5b628cffed20b794d319710042 /src
parent26241c70ac144eb3eb90b4336ecf6ad5248a367b (diff)
downloadjustbuild-d57a7bf8964de96456bd0f9a886c9f2cfa326e60.tar.gz
Fix wrong assembly of just args in just-mr
The actual error fixed in this commit was the usage of the std::vector resize method instead of the reserve method. The resize method increases the size of the vector by appending new default-allocated elements (empty strings in this case), whereas the reserve method just increases the underlying capacity of the vector without appending elements. In addition to this fix, the remaining just-args assembly code was refactored to drop the lambda-function usage in favor of a plain sequence of statements.
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/just_mr/main.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index d63448d7..08f82f32 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -350,16 +350,13 @@ void SetupDefaultLogging() {
if (just_args.IsNotNull()) {
for (auto const& [cmd_name, cmd_args] : just_args->Map()) {
// get list of string args for current command
- clargs->just_cmd.just_args[cmd_name] =
- [&cmd_args = cmd_args]() -> std::vector<std::string> {
- std::vector<std::string> args{};
- auto const& args_list = cmd_args->List();
- args.resize(args_list.size());
- for (auto const& arg : args_list) {
- args.emplace_back(arg->String());
- }
- return args;
- }();
+ std::vector<std::string> args{};
+ auto const& args_list = cmd_args->List();
+ args.reserve(args_list.size());
+ for (auto const& arg : args_list) {
+ args.emplace_back(arg->String());
+ }
+ clargs->just_cmd.just_args[cmd_name] = std::move(args);
}
}
// read config lookup order