mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-06-15 08:17:05 +00:00
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:
committed by
Dennis Klein
parent
7a44c5e19e
commit
0feda158b4
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user