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>
This commit is contained in:
parent
1016c0af74
commit
f4950cb6e1
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user