Skip to content

Commit

Permalink
Use references as loop variables
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-shirshov committed Apr 3, 2018
1 parent cfee528 commit bac891b
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions common/ipaddresses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using namespace swss;
IpAddresses::IpAddresses(const string &ipsStr)
{
auto ips = tokenize(ipsStr, IP_DELIMITER);
for (auto ip : ips)
for (const auto& ip : ips)
m_ips.insert(ip);
}

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

bool IpAddresses::contains(const IpAddresses &ips) const
{
for (auto ip : ips.getIpAddresses())
for (const auto& ip : ips.getIpAddresses())
{
if (!contains(ip))
{
Expand Down
2 changes: 1 addition & 1 deletion common/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ string JSon::buildJson(const vector<FieldValueTuple> &fv)
nlohmann::json j = nlohmann::json::array();

// we use array to save order
for (auto &i : fv)
for (const auto& i : fv)
{
j.push_back(fvField(i));
j.push_back(fvValue(i));
Expand Down
2 changes: 1 addition & 1 deletion common/producerstatetable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void ProducerStateTable::set(string key, vector<FieldValueTuple> &values,

args.push_back("G");
args.push_back(key);
for (auto& iv: values)
for (const auto& iv: values)
{
args.push_back(fvField(iv));
args.push_back(fvValue(iv));
Expand Down
2 changes: 1 addition & 1 deletion common/producertable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void ProducerTable::set(string key, vector<FieldValueTuple> &values, string op,
json j;
string json_key = getKeyName(key);
j[json_key] = json::object();
for (auto it : values)
for (const auto& it : values)
j[json_key][fvField(it)] = fvValue(it);
j["OP"] = op;
m_dumpFile << j.dump(4);
Expand Down
2 changes: 1 addition & 1 deletion common/rediscommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void RedisCommand::formatHMSET(const std::string &key,

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

for (const auto &fvt: values)
for (const auto& fvt: values)
{
args.push_back(fvField(fvt).c_str());
args.push_back(fvValue(fvt).c_str());
Expand Down
2 changes: 1 addition & 1 deletion common/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void Select::removeSelectable(Selectable *selectable)

void Select::addSelectables(vector<Selectable *> selectables)
{
for(auto it : selectables)
for(const auto& it : selectables)
{
addSelectable(it);
}
Expand Down
4 changes: 2 additions & 2 deletions common/subscriberstatetable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SubscriberStateTable::SubscriberStateTable(DBConnector *db, string tableName, in
vector<string> keys;
m_table.getKeys(keys);

for (auto key: keys)
for (const auto& key: keys)
{
KeyOpFieldsValuesTuple kco;

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

while (auto event = popEventBuffer())
while (const auto& event = popEventBuffer())
{
KeyOpFieldsValuesTuple kco;
/* if the Key-space notification is empty, try next one. */
Expand Down
2 changes: 1 addition & 1 deletion common/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void TableEntryEnumerable::getContent(vector<KeyOpFieldsValuesTuple> &tuples)

tuples.clear();

for (auto key: keys)
for (const auto& key: keys)
{
vector<FieldValueTuple> values;
string op = "";
Expand Down

0 comments on commit bac891b

Please sign in to comment.