From 6aa97ce7982b78a26803908c0ce12302e51df793 Mon Sep 17 00:00:00 2001 From: pavel-shirshov Date: Mon, 28 Sep 2020 10:00:34 -0700 Subject: [PATCH] Use .clear() after std::move() (#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. --- orchagent/fdborch.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/orchagent/fdborch.cpp b/orchagent/fdborch.cpp index 9d587cb55a14..0c75d0c8e4dc 100644 --- a/orchagent/fdborch.cpp +++ b/orchagent/fdborch.cpp @@ -556,14 +556,12 @@ void FdbOrch::updateVlanMember(const VlanMemberUpdate& update) string port_name = update.member.m_alias; auto fdb_list = std::move(saved_fdb_entries[port_name]); - if(!fdb_list.empty()) + saved_fdb_entries[port_name].clear(); + for (const auto& fdb: fdb_list) { - for (const auto& fdb: fdb_list) - { - // try to insert an FDB entry. If the FDB entry is not ready to be inserted yet, - // it would be added back to the saved_fdb_entries structure by addFDBEntry() - (void)addFdbEntry(fdb.entry, fdb.type); - } + // try to insert an FDB entry. If the FDB entry is not ready to be inserted yet, + // it would be added back to the saved_fdb_entries structure by addFDBEntry() + (void)addFdbEntry(fdb.entry, fdb.type); } }