summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_engine/executor/executor.hpp
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/buildtool/execution_engine/executor/executor.hpp
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/buildtool/execution_engine/executor/executor.hpp')
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp8
1 files changed, 4 insertions, 4 deletions
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<DependencyGraph::NamedArtifactNodePtr> const& artifacts)
-> std::optional<ArtifactDigest> {
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;
}