Before add ing a new state to diff log, trying to remove one that has the same hash.
Note that all pointers to next diff state will be preserved as it is
(thanks to shared_ptr).
There is a need for next pointer optimizations, but we can postpone it
until we implement diff log flattening functionality.
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index 37c79de..7eba7c6 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -204,6 +204,8 @@
{
m_log.get<sequenced> ().front ()->setNext (diffLog);
}
+ m_log.erase (m_state.getDigest());
+ /// @todo Optimization
m_log.insert (diffLog);
}
catch (Error::SyncXmlDecodingFailure &e)
@@ -225,11 +227,13 @@
recursive_mutex::scoped_lock lock (m_stateMutex);
diffLog->setDigest (m_state.getDigest());
- if (m_log.get<sequenced> ().size () > 0)
+ if (m_log.size () > 0)
{
m_log.get<sequenced> ().front ()->setNext (diffLog);
}
- m_log.get<sequenced> ().push_back (diffLog);
+ m_log.erase (m_state.getDigest()); // remove diff state with the same digest. next pointers are still valid
+ /// @todo Optimization
+ m_log.insert (diffLog);
vector<string> pis = m_syncInterestTable.fetchAll ();
if (pis.size () > 0)