summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvector.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-10-01 10:11:11 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-10-01 18:25:57 +0200
commitf17e0b589309eda4dfbbca266fbe3d87e548d8a3 (patch)
tree600e9262dba3ed5912933230c219a229e17489f8 /src/corelib/tools/qvector.h
parentdb1db22818949ed112a7208b6063b208952e95ea (diff)
QList: iterate forward in contains()
After much head-scratching, we found no reason for the backwards iteration. Indeed, forward iteration should be slightly faster than backwards, because it operates in the direction in which cache-lines are filled, usually. This is in preparation of using std algorithms instead of hand-written loops. It avoids having to use std::reverse_iterator. Change-Id: Id2388eab2339c24deb93095495d87056a9c57133 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r--src/corelib/tools/qvector.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 83b836711d..8b0804e5df 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -791,10 +791,10 @@ int QVector<T>::lastIndexOf(const T &t, int from) const
template <typename T>
bool QVector<T>::contains(const T &t) const
{
- T* b = d->begin();
- T* i = d->end();
- while (i != b)
- if (*--i == t)
+ T* i = d->begin();
+ T* e = d->end();
+ for (; i != e; ++i)
+ if (*i == t)
return true;
return false;
}