perf: avoid copies in range-based for loops

- take loop variables by const reference where the body does not modify
  them
- clang-tidy performance-for-range-copy
  https://clang.llvm.org/extra/clang-tidy/checks/performance/for-range-copy.html
This commit is contained in:
Dennis Klein
2026-06-09 19:59:32 +02:00
committed by Dennis Klein
parent 7a44c5e19e
commit 0feda158b4
3 changed files with 4 additions and 4 deletions

View File

@@ -79,7 +79,7 @@ Properties SuboptParser(const vector<string>& channelConfig, const string& devic
ptree channelsArray;
for (auto token : channelConfig) {
for (const auto& token : channelConfig) {
string channelName;
ptree channelProperties;

View File

@@ -71,7 +71,7 @@ class Poller final : public fair::mq::Poller
try {
int offset = 0;
// calculate offsets and the total size of the poll item set
for (std::string channel : channelList) {
for (const std::string& channel : channelList) {
fOffsetMap[channel] = offset;
offset += channelsMap.at(channel).size();
fNumItems += channelsMap.at(channel).size();
@@ -80,7 +80,7 @@ class Poller final : public fair::mq::Poller
fItems = new zmq_pollitem_t[fNumItems];
int index = 0;
for (std::string channel : channelList) {
for (const std::string& channel : channelList) {
for (unsigned int i = 0; i < channelsMap.at(channel).size(); ++i) {
index = fOffsetMap[channel] + i;

View File

@@ -86,7 +86,7 @@ class Poller final : public fair::mq::Poller
fItems = new zmq_pollitem_t[fNumItems];
int index = 0;
for (std::string channel : channelList) {
for (const std::string& channel : channelList) {
for (unsigned int i = 0; i < channelsMap.at(channel).size(); ++i) {
index = fOffsetMap[channel] + i;