Skip to content

Commit

Permalink
[qtcontacts-sqlite] Remove duplicated effort from delta detection. Co…
Browse files Browse the repository at this point in the history
…ntributes to JB#32526

The delta-detection algorithm calculates the entire set of possible
permutations of (added, removed) details to determine the likely
set of (modified) details.

This commit ensures that the entire set of possible permutations for
each detail type is only calculated once, rather than once for
each potential modification.

Contributes to JB#32526
  • Loading branch information
Chris Adams committed Feb 25, 2016
1 parent 885a8d5 commit c30a0ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/extensions/twowaycontactsyncadapter_impl.h
Expand Up @@ -938,7 +938,7 @@ QList<QContactDetail> TwoWayContactSyncAdapterPrivate::improveDelta(QList<QConta
bucketedAdditions.insertMulti(additions->at(i).type(), additions->at(i));

QSet<int> seenTypes;
foreach (int type, bucketedRemovals.keys()) {
foreach (int type, bucketedRemovals.uniqueKeys()) {
QTCONTACTS_SQLITE_TWCSA_DEBUG_LOG("dealing with detail type:" << type);
seenTypes.insert(type);
QList<QContactDetail> removalsOfThisType = bucketedRemovals.values(type);
Expand All @@ -952,7 +952,7 @@ QList<QContactDetail> TwoWayContactSyncAdapterPrivate::improveDelta(QList<QConta
finalModifications.append(modificationsOfThisType);
}

foreach (int type, bucketedAdditions.keys()) {
foreach (int type, bucketedAdditions.uniqueKeys()) {
if (!seenTypes.contains(type)) {
finalAdditions.append(bucketedAdditions.values(type));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/benchmarks/deltadetection/deltasyncadapter.h
Expand Up @@ -30,8 +30,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/

#ifndef TESTSYNCADAPTER_H
#define TESTSYNCADAPTER_H
#ifndef DELTASYNCADAPTER_H
#define DELTASYNCADAPTER_H

#include "../../../src/extensions/twowaycontactsyncadapter.h"
#include <QContactManager>
Expand Down Expand Up @@ -106,4 +106,4 @@ class DeltaSyncAdapter : public QObject, public QtContactsSqliteExtensions::TwoW
mutable QMap<QString, QMultiMap<QString, QString> > m_remoteServerDuplicates; // accountId to originalGuid to duplicateGuids.
};

#endif
#endif // DELTASYNCADAPTER_H

0 comments on commit c30a0ed

Please sign in to comment.