Skip to content

Commit

Permalink
Minor modifications
Browse files Browse the repository at this point in the history
Moved declarations inside the loop and avoid clear usage.
  • Loading branch information
arfeigin authored Nov 23, 2022
1 parent 7c844db commit 66dd31a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions cfgmgr/coppmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,6 @@ void CoppMgr::mergeConfig(CoppCfg &init_cfg, CoppCfg &m_cfg, std::vector<std::st
* user config) will overwrie the copp table entries, current entry will be deleted from copp
* tables.
*/
unordered_map<string, string> preserved_copp_entry;
unordered_map<string, string>::const_iterator preserved_copp_it;
string field;
string value;
for (auto i : helper)
{
string table_key = i.first;
Expand All @@ -281,15 +277,16 @@ void CoppMgr::mergeConfig(CoppCfg &init_cfg, CoppCfg &m_cfg, std::vector<std::st
}
else
{
unordered_map<string, string> preserved_copp_entry;
for (auto prev_fv : preserved_fvs)
{
preserved_copp_entry[fvField(prev_fv)] = fvValue(prev_fv);
}
for (auto helper_fv: helper_fvs)
{
field = fvField(helper_fv);
value = fvValue(helper_fv);
preserved_copp_it = preserved_copp_entry.find(field);
string field = fvField(helper_fv);
string value = fvValue(helper_fv);
unordered_map<string, string>::const_iterator preserved_copp_it = preserved_copp_entry.find(field);
bool field_found = (preserved_copp_it != preserved_copp_entry.end());
bool overwrite = false;
if (field_found)
Expand All @@ -315,7 +312,6 @@ void CoppMgr::mergeConfig(CoppCfg &init_cfg, CoppCfg &m_cfg, std::vector<std::st
{
m_cfg[table_key] = new_fvs;
}
preserved_copp_entry.clear();
}
}
}
Expand Down

0 comments on commit 66dd31a

Please sign in to comment.