From 676b912cf93a2902b7feca2f121f10dedb9d9b71 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Fri, 27 Nov 2020 19:37:11 +0100 Subject: [PATCH] QList docs: extend prepend() description Current description was confronting the general description of the class, which states that prepend() is fast. The updated description gives more information about the method's behavior in different conditions. Task-number: QTBUG-87962 Change-Id: I7b6dfb536d143d78c441214f83320c1bf1263e0d Reviewed-by: Thiago Macieira (cherry picked from commit 6364194456ec92a2c09a339d20b868bb49bd00e9) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/tools/qlist.qdoc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/corelib/tools/qlist.qdoc b/src/corelib/tools/qlist.qdoc index 4f78f75dc05..fecdf0028f2 100644 --- a/src/corelib/tools/qlist.qdoc +++ b/src/corelib/tools/qlist.qdoc @@ -681,11 +681,12 @@ This is the same as list.insert(0, \a value). - For large lists, this operation can be slow (\l{linear time}), - because it requires moving all the items in the list by one - position further in memory. If you want a container class that - provides a fast prepend operation, use std::list - instead. + Normally this operation is relatively fast (amortized \l{constant time}). + QList is able to allocate extra memory at the beginning of the list data + and grow in that direction without reallocating or moving the data on each + operation. However if you want a container class with a guarantee of + \l{constant time} prepend, use std::list instead, + but prefer QList otherwise. \sa append(), insert() */