summaryrefslogtreecommitdiff
path: root/src/other_tools/repo_map
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/repo_map
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/repo_map')
-rw-r--r--src/other_tools/repo_map/repos_to_setup_map.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/other_tools/repo_map/repos_to_setup_map.cpp b/src/other_tools/repo_map/repos_to_setup_map.cpp
index 4e29ffc2..7aeb69f7 100644
--- a/src/other_tools/repo_map/repos_to_setup_map.cpp
+++ b/src/other_tools/repo_map/repos_to_setup_map.cpp
@@ -502,7 +502,8 @@ void DistdirCheckout(ExpressionPtr const& repo_desc,
}
// get repo_type
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)(fmt::format("DistdirCheckout: Unknown type {} for "
"repository {}",
nlohmann::json(repo_type_str).dump(),
@@ -511,7 +512,7 @@ void DistdirCheckout(ExpressionPtr const& repo_desc,
return;
}
// only do work if repo is archive type
- if (kCheckoutTypeMap.at(repo_type_str) == CheckoutType::Archive) {
+ if (checkout_type_it->second == CheckoutType::Archive) {
auto const archive =
ParseArchiveContent(*resolved_repo_desc, dist_repo_name);
if (not archive) {
@@ -794,7 +795,8 @@ auto CreateReposToSetupMap(
}
// get repo_type
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)(
fmt::format("Config: Unknown type {} for repository {}",
nlohmann::json(repo_type_str).dump(),
@@ -811,7 +813,7 @@ auto CreateReposToSetupMap(
fatal);
});
// do checkout
- switch (kCheckoutTypeMap.at(repo_type_str)) {
+ switch (checkout_type_it->second) {
case CheckoutType::Git: {
GitCheckout(*resolved_repo_desc,
std::move(repos),