From 223f67c2cbf4648c3aaa907ec0edf98e53b574e9 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 13 Jun 2025 13:14:27 +0200 Subject: 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. --- src/other_tools/just_mr/update.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/other_tools/just_mr/update.cpp') 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 #include #include +#include #include #include "fmt/core.h" @@ -118,7 +119,8 @@ auto MultiRepoUpdate(std::shared_ptr 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 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) { -- cgit v1.2.3