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/buildtool/execution_engine/executor/executor.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/buildtool/execution_engine/executor/executor.hpp') diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index f009783d..5f5c2e92 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -632,8 +632,8 @@ class ExecutorImpl { std::vector const& artifacts) -> std::optional { if (artifacts.size() == 1 and - (artifacts.at(0).path == "." or artifacts.at(0).path.empty())) { - auto const& info = artifacts.at(0).node->Content().Info(); + (artifacts[0].path == "." or artifacts[0].path.empty())) { + auto const& info = artifacts[0].node->Content().Info(); if (info and IsTreeObject(info->type)) { // Artifact list contains single tree with path "." or "". Reuse // the existing tree artifact by returning its digest. @@ -831,7 +831,7 @@ class ExecutorImpl { msg << nlohmann::json(action->Env()).dump(); } auto const& origin_map = progress->OriginMap(); - auto origins = origin_map.find(action->Content().Id()); + auto const origins = origin_map.find(action->Content().Id()); if (origins != origin_map.end() and not origins->second.empty()) { msg << "\nrequested by"; for (auto const& origin : origins->second) { @@ -887,7 +887,7 @@ class ExecutorImpl { remote_context->exec_config->dispatch) { bool match = true; for (auto const& [k, v] : pred) { - auto v_it = properties.find(k); + auto const v_it = properties.find(k); if (not(v_it != properties.end() and v_it->second == v)) { match = false; } -- cgit v1.2.3