From 32bb2177181c24eb1245c6e57ffbc7cc5e1e406b Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sat, 14 Sep 2024 09:41:58 -0400 Subject: [PATCH] Optimization: use a const & to avoid copy when traversing matrix this substantially reduces the cost of a process with empty matrix --- include/sst/basic-blocks/mod-matrix/ModMatrix.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/sst/basic-blocks/mod-matrix/ModMatrix.h b/include/sst/basic-blocks/mod-matrix/ModMatrix.h index cf38401..51d26da 100644 --- a/include/sst/basic-blocks/mod-matrix/ModMatrix.h +++ b/include/sst/basic-blocks/mod-matrix/ModMatrix.h @@ -298,12 +298,12 @@ template struct FixedMatrix : ModMatrixbaseValues.at(tgt); } - for (auto r : routingValuePointers) + for (const auto &r : routingValuePointers) { - if (r.active && !(*r.active)) + if (!r.source || !r.target) continue; - if (!r.source || !r.target) + if (r.active && !(*r.active)) continue; float sourceViaVal{1.f};