summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlist.h
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-03-15 14:25:26 +0100
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-03-15 21:13:30 +0100
commit835b795c3dd752f11c11178bf52b018ddc76b368 (patch)
tree95cb3db914dde84c2b1aaa59b84c615912f09d44 /src/corelib/tools/qlist.h
parentd4d7f3575c229848f08c7df75a1281755d6c41a8 (diff)
detach in fewer cases, remove redundant calculation
Reviewed-by: thiago
Diffstat (limited to 'src/corelib/tools/qlist.h')
-rw-r--r--src/corelib/tools/qlist.h4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index c6dd106163..dc8c849e8b 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -636,12 +636,10 @@ 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)
+ if (alength < 0 || pos + alength > size())
alength = size() - pos;
if (pos == 0 && alength == size())
return *this;
- if (pos + alength > size())
- alength = size() - pos;
QList<T> cpy;
cpy.reserve(alength);
cpy.d->end = alength;