diff --git a/warmrestart/warmRestartAssist.cpp b/warmrestart/warmRestartAssist.cpp index 3006fbf157b1..03baa0df63c3 100644 --- a/warmrestart/warmRestartAssist.cpp +++ b/warmrestart/warmRestartAssist.cpp @@ -1,4 +1,5 @@ #include +#include #include "logger.h" #include "schema.h" #include "warm_restart.h" @@ -173,7 +174,7 @@ void AppRestartAssist::insertToMap(string key, vector fvVector, else if (found != appTableCacheMap.end()) { // check only the original vector range (exclude cache-state field/value) - if(!equal(fvVector.begin(), fvVector.end(), found->second.begin())) + if(! contains(found->second, fvVector)) { SWSS_LOG_NOTICE("%s, found key: %s, new value ", m_appTableName.c_str(), key.c_str()); @@ -280,3 +281,18 @@ bool AppRestartAssist::checkReconcileTimer(Selectable *s) } return false; } + +// check if left vector contains all elements of right vector +bool AppRestartAssist::contains(const std::vector& left, + const std::vector& right) +{ + for (auto const& rv : right) + { + if (std::find(left.begin(), left.end(), rv) == left.end()) + { + return false; + } + } + + return true; +} diff --git a/warmrestart/warmRestartAssist.h b/warmrestart/warmRestartAssist.h index 669f101e8e7b..2d5e387ee130 100644 --- a/warmrestart/warmRestartAssist.h +++ b/warmrestart/warmRestartAssist.h @@ -115,6 +115,8 @@ class AppRestartAssist std::string joinVectorString(const std::vector &fv); void setCacheEntryState(std::vector &fvVector, cache_state_t state); cache_state_t getCacheEntryState(const std::vector &fvVector); + bool contains(const std::vector& left, + const std::vector& right); }; }