summaryrefslogtreecommitdiff
path: root/src/other_tools/just_mr/update.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-06-13 13:14:27 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-06-16 17:27:29 +0200
commit223f67c2cbf4648c3aaa907ec0edf98e53b574e9 (patch)
tree7dd1e9aa2dd8a2470984a65d841e222b2226fa59 /src/other_tools/just_mr/update.cpp
parentfebe0937cf4394bc0f908e13fd0b6ab63b2c29c2 (diff)
downloadjustbuild-223f67c2cbf4648c3aaa907ec0edf98e53b574e9.tar.gz
Avoid unnecessary work in accessing container entries
- in sequence containers, use operator[] instead of .at() when accessing indices guaranteed to be in bound; - in associative containers, prefer .find() and reusing the returned const iterator to using .contains() and .at(); while there, make any so obtained iterators const if they are read-only.
Diffstat (limited to 'src/other_tools/just_mr/update.cpp')
-rw-r--r--src/other_tools/just_mr/update.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/other_tools/just_mr/update.cpp b/src/other_tools/just_mr/update.cpp
index e2ed9197..43fd2de6 100644
--- a/src/other_tools/just_mr/update.cpp
+++ b/src/other_tools/just_mr/update.cpp
@@ -24,6 +24,7 @@
#include <optional>
#include <thread>
#include <unordered_map>
+#include <utility>
#include <vector>
#include "fmt/core.h"
@@ -118,7 +119,8 @@ auto MultiRepoUpdate(std::shared_ptr<Configuration> const& config,
return kExitUpdateError;
}
auto repo_type_str = repo_type->get()->String();
- if (not kCheckoutTypeMap.contains(repo_type_str)) {
+ auto const checkout_type_it = kCheckoutTypeMap.find(repo_type_str);
+ if (checkout_type_it == kCheckoutTypeMap.end()) {
Logger::Log(LogLevel::Error,
"Unknown repository type {} for {}",
nlohmann::json(repo_type_str).dump(),
@@ -126,7 +128,7 @@ auto MultiRepoUpdate(std::shared_ptr<Configuration> const& config,
return kExitUpdateError;
}
// only do work if repo is git type
- if (kCheckoutTypeMap.at(repo_type_str) == CheckoutType::Git) {
+ if (checkout_type_it->second == CheckoutType::Git) {
auto repo_desc_repository =
(*resolved_repo_desc)->At("repository");
if (not repo_desc_repository) {