Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit bac891b

Browse files
Use references as loop variables
1 parent cfee528 commit bac891b

8 files changed

Lines changed: 10 additions & 10 deletions

File tree

common/ipaddresses.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using namespace swss;
1111
IpAddresses::IpAddresses(const string &ipsStr)
1212
{
1313
auto ips = tokenize(ipsStr, IP_DELIMITER);
14-
for (auto ip : ips)
14+
for (const auto& ip : ips)
1515
m_ips.insert(ip);
1616
}
1717

@@ -39,7 +39,7 @@ bool IpAddresses::contains(const IpAddress &ip) const
3939

4040
bool IpAddresses::contains(const IpAddresses &ips) const
4141
{
42-
for (auto ip : ips.getIpAddresses())
42+
for (const auto& ip : ips.getIpAddresses())
4343
{
4444
if (!contains(ip))
4545
{

common/json.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ string JSon::buildJson(const vector<FieldValueTuple> &fv)
1313
nlohmann::json j = nlohmann::json::array();
1414

1515
// we use array to save order
16-
for (auto &i : fv)
16+
for (const auto& i : fv)
1717
{
1818
j.push_back(fvField(i));
1919
j.push_back(fvValue(i));

common/producerstatetable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void ProducerStateTable::set(string key, vector<FieldValueTuple> &values,
6969

7070
args.push_back("G");
7171
args.push_back(key);
72-
for (auto& iv: values)
72+
for (const auto& iv: values)
7373
{
7474
args.push_back(fvField(iv));
7575
args.push_back(fvValue(iv));

common/producertable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void ProducerTable::set(string key, vector<FieldValueTuple> &values, string op,
8989
json j;
9090
string json_key = getKeyName(key);
9191
j[json_key] = json::object();
92-
for (auto it : values)
92+
for (const auto& it : values)
9393
j[json_key][fvField(it)] = fvValue(it);
9494
j["OP"] = op;
9595
m_dumpFile << j.dump(4);

common/rediscommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void RedisCommand::formatHMSET(const std::string &key,
4747

4848
std::vector<const char*> args = { cmd, key.c_str() };
4949

50-
for (const auto &fvt: values)
50+
for (const auto& fvt: values)
5151
{
5252
args.push_back(fvField(fvt).c_str());
5353
args.push_back(fvValue(fvt).c_str());

common/select.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void Select::removeSelectable(Selectable *selectable)
8181

8282
void Select::addSelectables(vector<Selectable *> selectables)
8383
{
84-
for(auto it : selectables)
84+
for(const auto& it : selectables)
8585
{
8686
addSelectable(it);
8787
}

common/subscriberstatetable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ SubscriberStateTable::SubscriberStateTable(DBConnector *db, string tableName, in
2727
vector<string> keys;
2828
m_table.getKeys(keys);
2929

30-
for (auto key: keys)
30+
for (const auto& key: keys)
3131
{
3232
KeyOpFieldsValuesTuple kco;
3333

@@ -98,7 +98,7 @@ void SubscriberStateTable::pops(deque<KeyOpFieldsValuesTuple> &vkco, string /*pr
9898
return;
9999
}
100100

101-
while (auto event = popEventBuffer())
101+
while (const auto& event = popEventBuffer())
102102
{
103103
KeyOpFieldsValuesTuple kco;
104104
/* if the Key-space notification is empty, try next one. */

common/table.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void TableEntryEnumerable::getContent(vector<KeyOpFieldsValuesTuple> &tuples)
9898

9999
tuples.clear();
100100

101-
for (auto key: keys)
101+
for (const auto& key: keys)
102102
{
103103
vector<FieldValueTuple> values;
104104
string op = "";

0 commit comments

Comments
 (0)