Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,13 @@ void FdbOrch::update(sai_fdb_event_t type,
update.entry.mac.to_string().c_str(),
vlanName.c_str(), update.port.m_alias.c_str());

for (const auto& itr : m_entries)
for (auto itr = m_entries.begin(); itr != m_entries.end();)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
Just a suggestion, can we just update the for loop to the below, instead of increment iterator at multiple places?

for (auto itr = m_entries.begin(); itr != m_entries.end(); itr = next_item)
{
    auto next_item = std::next(itr, 1);
    .....
    ....
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoided multiple iterator increment. Updated patch. Pls check.

{
if (itr.port_name == update.port.m_alias)
auto next_item = std::next(itr);
if (itr->port_name == update.port.m_alias)
{
update.entry.mac = itr.mac;
update.entry.bv_id = itr.bv_id;
update.entry.mac = itr->mac;
update.entry.bv_id = itr->bv_id;
update.add = false;

storeFdbEntryState(update);
Expand All @@ -246,7 +247,8 @@ void FdbOrch::update(sai_fdb_event_t type,
{
observer->update(SUBJECT_TYPE_FDB_CHANGE, &update);
}
}
}
itr = next_item;
}
}
else if (bridge_port_id == SAI_NULL_OBJECT_ID)
Expand Down