diff options
Diffstat (limited to 'src/corelib/tools/qlist.h')
-rw-r--r-- | src/corelib/tools/qlist.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 9e4ba70908..4c52c22300 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -45,6 +45,7 @@ #include <QtCore/qalgorithms.h> #include <QtCore/qiterator.h> #include <QtCore/qrefcount.h> +#include <QtCore/qarraydata.h> #include <iterator> #include <list> @@ -646,10 +647,17 @@ inline void QList<T>::move(int from, int to) template<typename T> Q_OUTOFLINE_TEMPLATE QList<T> QList<T>::mid(int pos, int alength) const { - if (alength < 0 || pos > size() - alength) - alength = size() - pos; - if (pos == 0 && alength == size()) + using namespace QtPrivate; + switch (QContainerImplHelper::mid(size(), &pos, &alength)) { + case QContainerImplHelper::Null: + case QContainerImplHelper::Empty: + return QList<T>(); + case QContainerImplHelper::Full: return *this; + case QContainerImplHelper::Subset: + break; + } + QList<T> cpy; if (alength <= 0) return cpy; |