summaryrefslogtreecommitdiffstats
path: root/src/contacts/qcontactmanager_p.cpp
diff options
context:
space:
mode:
authorMatt Vogt <matthew.vogt@jollamobile.com>2014-08-04 09:52:09 +1000
committerMatthew Vogt <matthew.vogt@qinetic.com.au>2014-08-08 11:39:58 +0200
commit74dbcf9260a2557175a9cca2e6de21aa4da0ad03 (patch)
treeabc133fd2775b26273d02f488d1b75b48bd917b1 /src/contacts/qcontactmanager_p.cpp
parent7a2b179ff1cf1bffb378272e2d339bc803700e37 (diff)
Cache deserialized manager URIs to promote data sharing
When deserializing ID objects, construct the resulting objects from cached instances of the manager URI string so that the resulting ID objects can share a string data representation. Change-Id: If3091bfc42e61938a823a9d2bfc68d0dafec0977 Reviewed-by: Christopher Adams <chris.adams@jollamobile.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/contacts/qcontactmanager_p.cpp')
-rw-r--r--src/contacts/qcontactmanager_p.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/contacts/qcontactmanager_p.cpp b/src/contacts/qcontactmanager_p.cpp
index 9472c00e6..4f42e0ac3 100644
--- a/src/contacts/qcontactmanager_p.cpp
+++ b/src/contacts/qcontactmanager_p.cpp
@@ -425,7 +425,7 @@ bool QContactManagerData::parseIdString(const QString &idString, QString *manage
*managerName = unescapeParam(mgrName);
if (managerUri)
- *managerUri = prefix + QLatin1Char(':') + mgrName + QLatin1Char(':') + paramString;
+ *managerUri = cachedUri(prefix + QLatin1Char(':') + mgrName + QLatin1Char(':') + paramString);
// and unescape the engine id string
if (engineIdString)
@@ -479,4 +479,21 @@ QString QContactManagerData::buildIdString(const QString &managerName, const QMa
return idString;
}
+/*!
+ Returns a cached instance of the manager URI string that matches \a managerUri.
+ This instance should be preferred when constructing ID objects in order to promote
+ data sharing of the URI string.
+*/
+QString QContactManagerData::cachedUri(const QString &managerUri)
+{
+ static QStringList managerUris;
+
+ int index = managerUris.indexOf(managerUri);
+ if (index != -1)
+ return managerUris.at(index);
+
+ managerUris.append(managerUri);
+ return managerUri;
+}
+
QT_END_NAMESPACE_CONTACTS