diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-07-08 19:33:02 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-07-14 04:20:41 +0000 |
commit | f4950cb6e15a7a6c1a6732c9a5ec9d59a2952948 (patch) | |
tree | de5aaa2778f8aeaa87d18d3e5c255f4cc7a43300 /src/corelib/serialization/qcbormap.h | |
parent | 1016c0af740ebdf4b7dccfe5db5d63f07e4fee00 (diff) |
QCborMap: make take() & remove() efficient if the item isn't there
By using constFind(), we won't detach if the item isn't there. Both
extract() and erase() can take const_iterators.
Change-Id: Id59bdd8f1a804b809e22fffd153f92989ef84644
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qcbormap.h')
-rw-r--r-- | src/corelib/serialization/qcbormap.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/corelib/serialization/qcbormap.h b/src/corelib/serialization/qcbormap.h index 15c9a5c50c..02c2ec086d 100644 --- a/src/corelib/serialization/qcbormap.h +++ b/src/corelib/serialization/qcbormap.h @@ -208,21 +208,21 @@ public: QCborValueRef operator[](const QCborValue &key); QCborValue take(qint64 key) - { iterator it = find(key); if (it != end()) return extract(it); return QCborValue(); } + { const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); } QCborValue take(QLatin1String key) - { iterator it = find(key); if (it != end()) return extract(it); return QCborValue(); } + { const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); } QCborValue take(const QString &key) - { iterator it = find(key); if (it != end()) return extract(it); return QCborValue(); } + { const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); } QCborValue take(const QCborValue &key) - { iterator it = find(key); if (it != end()) return extract(it); return QCborValue(); } + { const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); } void remove(qint64 key) - { iterator it = find(key); if (it != end()) erase(it); } + { const_iterator it = constFind(key); if (it != constEnd()) erase(it); } void remove(QLatin1String key) - { iterator it = find(key); if (it != end()) erase(it); } + { const_iterator it = constFind(key); if (it != constEnd()) erase(it); } void remove(const QString & key) - { iterator it = find(key); if (it != end()) erase(it); } + { const_iterator it = constFind(key); if (it != constEnd()) erase(it); } void remove(const QCborValue &key) - { iterator it = find(key); if (it != end()) erase(it); } + { const_iterator it = constFind(key); if (it != constEnd()) erase(it); } bool contains(qint64 key) const { const_iterator it = find(key); return it != end(); } bool contains(QLatin1String key) const |