Skip to content

Commit 6aa97ce

Browse files
Use .clear() after std::move() (sonic-net#1444)
1. Use .clear() after std::move from the vector to make sure that the vector is in a correct state. 2. Remove the if condition which is not required here.
1 parent d5757db commit 6aa97ce

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

orchagent/fdborch.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,12 @@ void FdbOrch::updateVlanMember(const VlanMemberUpdate& update)
556556

557557
string port_name = update.member.m_alias;
558558
auto fdb_list = std::move(saved_fdb_entries[port_name]);
559-
if(!fdb_list.empty())
559+
saved_fdb_entries[port_name].clear();
560+
for (const auto& fdb: fdb_list)
560561
{
561-
for (const auto& fdb: fdb_list)
562-
{
563-
// try to insert an FDB entry. If the FDB entry is not ready to be inserted yet,
564-
// it would be added back to the saved_fdb_entries structure by addFDBEntry()
565-
(void)addFdbEntry(fdb.entry, fdb.type);
566-
}
562+
// try to insert an FDB entry. If the FDB entry is not ready to be inserted yet,
563+
// it would be added back to the saved_fdb_entries structure by addFDBEntry()
564+
(void)addFdbEntry(fdb.entry, fdb.type);
567565
}
568566
}
569567

0 commit comments

Comments
 (0)