summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlist.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-02-16 14:44:41 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-02-16 18:10:39 (GMT)
commit02135be18f3c4b1d1525aff6dfe96c9c8521084d (patch)
tree46dce069dfee63d0fe343af4ad12a548f8bbda8f /src/corelib/tools/qlist.cpp
parent5af4e7d0e44be7d35c38c439fa9fc42f54ccd09b (diff)
downloadQt-02135be18f3c4b1d1525aff6dfe96c9c8521084d.zip
Qt-02135be18f3c4b1d1525aff6dfe96c9c8521084d.tar.gz
Qt-02135be18f3c4b1d1525aff6dfe96c9c8521084d.tar.bz2
avoid double reallocations in appending operations
operator+=() and co. would first detach, and then realloc if they found the reservation too small. in particular, appending anything to an empty list would trigger this double reallocation (first copy shared_null, then grow the copy). Reviewed-by: joao Reviewed-by: denis
Diffstat (limited to 'src/corelib/tools/qlist.cpp')
-rw-r--r--src/corelib/tools/qlist.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index ac0dc46..a468c77 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -154,6 +154,19 @@ QListData::Data *QListData::detach(int alloc)
}
/*!
+ * Detaches the QListData by allocating new memory for a list which will be bigger
+ * than the copied one and is expected to grow further.
+ * Returns the old (shared) data, it is up to the caller to deref() and free()
+ * For the new data node_copy needs to be called.
+ *
+ * \internal
+ */
+QListData::Data *QListData::detach_grow(int alloc)
+{
+ return detach(grow(alloc));
+}
+
+/*!
* Detaches the QListData by reallocating new memory.
* Returns the old (shared) data, it is up to the caller to deref() and free()
* For the new data node_copy needs to be called.
@@ -596,6 +609,11 @@ void **QListData::erase(void **xi)
\internal
*/
+/*! \fn void QList::detach_grow(int alloc)
+
+ \internal
+*/
+
/*! \fn void QList::detachShared()
\internal