summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qcborarray.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-05-19 14:58:43 -0700
committerThiago Macieira <thiago.macieira@intel.com>2018-07-04 03:04:21 +0000
commit2bb44414ff456873c885391e4a03afb67e7306da (patch)
tree9d6f7d1b2912cd494073c10e23fd61543535a022 /src/corelib/serialization/qcborarray.h
parentfcb0f68e77bb69544f0ae310baffd3ceff8a9e5d (diff)
QCborArray & Map: implement efficient take() / extract()
Questions: 1) should QCborMap::extract return value_type (a pair) instead of just the value? 2) should the both return the iterator to the next element too, like erase()? Change-Id: I052407b777ec43f78378fffd15302a9c14468db3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qcborarray.h')
-rw-r--r--src/corelib/serialization/qcborarray.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/serialization/qcborarray.h b/src/corelib/serialization/qcborarray.h
index f10fcac2cb..0be362480c 100644
--- a/src/corelib/serialization/qcborarray.h
+++ b/src/corelib/serialization/qcborarray.h
@@ -192,8 +192,9 @@ public:
void insert(qsizetype i, const QCborValue &value);
void prepend(const QCborValue &value) { insert(0, value); }
void append(const QCborValue &value) { insert(-1, value); }
+ QCborValue extract(Iterator it);
void removeAt(qsizetype i);
- QCborValue takeAt(qsizetype i) { QCborValue v = at(i); removeAt(i); return v; }
+ QCborValue takeAt(qsizetype i) { Q_ASSERT(i < size()); return extract(begin() + i); }
void removeFirst() { removeAt(0); }
void removeLast() { removeAt(size() - 1); }
QCborValue takeFirst() { return takeAt(0); }