diff options
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r-- | src/corelib/tools/qvector.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 0a32c96958..9692477e18 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -822,12 +822,17 @@ int QVector<T>::count(const T &t) const template <typename T> Q_OUTOFLINE_TEMPLATE QVector<T> QVector<T>::mid(int pos, int len) const { - if (len < 0) - len = size() - pos; - if (pos == 0 && len == size()) + using namespace QtPrivate; + switch (QContainerImplHelper::mid(d->size, &pos, &len)) { + case QContainerImplHelper::Null: + case QContainerImplHelper::Empty: + return QVector<T>(); + case QContainerImplHelper::Full: return *this; - if (pos + len > size()) - len = size() - pos; + case QContainerImplHelper::Subset: + break; + } + QVector<T> copy; copy.reserve(len); for (int i = pos; i < pos + len; ++i) |