Branch 'kolab/integration/4.13.0' - akonadi/collectionsync.cpp
Christian Mollekopf
mollekopf at kolabsys.com
Tue Aug 12 00:16:01 CEST 2014
akonadi/collectionsync.cpp | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
New commits:
commit 4443c4f5524b12f7aeb68947911d0d44e85f1f07
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date: Mon Aug 11 23:58:41 2014 +0200
CollectionSync: Keep a hash of the names as well.
During the initial sync we hit this fallback codepath on every collection,
and it comes to a grinding halt with a couple of thousand collections.
With the hash it remains performant and the memory overhead seems relatively small.
diff --git a/akonadi/collectionsync.cpp b/akonadi/collectionsync.cpp
index e516bd9..4185a50 100644
--- a/akonadi/collectionsync.cpp
+++ b/akonadi/collectionsync.cpp
@@ -56,6 +56,7 @@ struct LocalNode
Collection collection;
QList<LocalNode *> childNodes;
QHash<QString, LocalNode *> childRidMap;
+ QHash<QString, LocalNode *> childNameMap;
/** When using hierarchical RIDs we attach a list of not yet processable remote nodes to
the closest already existing local ancestor node. They will be re-evaluated once a new
child node is added. */
@@ -149,6 +150,7 @@ public:
node->childNodes.append(childNode);
if (!childNode->collection.remoteId().isEmpty()) {
node->childRidMap.insert(childNode->collection.remoteId(), childNode);
+ node->childNameMap.insert(childNode->collection.name(), childNode);
}
}
}
@@ -159,6 +161,7 @@ public:
parentNode->childNodes.append(node);
if (!node->collection.remoteId().isEmpty()) {
parentNode->childRidMap.insert(node->collection.remoteId(), node);
+ parentNode->childNameMap.insert(node->collection.name(), node);
}
} else {
localPendingCollections[col.parentCollection().id()].append(col.id());
@@ -220,13 +223,12 @@ public:
if (localParentNode == localRoot) { // possibly non-unique names on top-level
return 0;
}
-
- foreach (LocalNode *childNode, localParentNode->childNodes) {
- // the restriction on empty RIDs can possibly removed, but for now I only understand the implication for this case
- if (childNode->collection.name() == name && childNode->collection.remoteId().isEmpty()) {
- return childNode;
- }
+ LocalNode *childNode = localParentNode->childNameMap.value(name, 0);
+ // the restriction on empty RIDs can possibly removed, but for now I only understand the implication for this case
+ if (childNode && childNode->collection.remoteId().isEmpty()) {
+ return childNode;
}
+
return 0;
}
More information about the commits
mailing list