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/fetch.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/other_tools/just_mr/fetch.cpp') diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index 3585d2f3..a7afc575 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -223,7 +223,8 @@ auto MultiRepoFetch(std::shared_ptr const& config, return kExitFetchError; } 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, "Config: Unknown repository type {} for {}", nlohmann::json(repo_type_str).dump(), @@ -231,7 +232,7 @@ auto MultiRepoFetch(std::shared_ptr const& config, return kExitFetchError; } // only do work if repo is archive or git tree type - switch (kCheckoutTypeMap.at(repo_type_str)) { + switch (checkout_type_it->second) { case CheckoutType::Archive: { auto logger = std::make_shared( [&repo_name](std::string const& msg, bool fatal) { -- cgit v1.2.3