summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvector.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-10-01 10:10:49 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-10-01 18:25:52 +0200
commitdb1db22818949ed112a7208b6063b208952e95ea (patch)
tree1ccadac9806a01dcdb3c040e2fd2e85090fb1329 /src/corelib/tools/qvector.h
parent5e01d3f64265867284e6bba8d1881e10c5d7605c (diff)
QVector: iterate forward in operator==
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: I180c52e0bb90e823216b77d3f49f2a3fd395567d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r--src/corelib/tools/qvector.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 07c66bc393..83b836711d 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -707,11 +707,11 @@ bool QVector<T>::operator==(const QVector<T> &v) const
return true;
if (d->size != v.d->size)
return false;
- T* b = d->begin();
- T* i = b + d->size;
- T* j = v.d->end();
- while (i != b)
- if (!(*--i == *--j))
+ T* e = d->end();
+ T* i = d->begin();
+ T* vi = v.d->begin();
+ for (; i != e; ++i, ++vi)
+ if (!(*i == *vi))
return false;
return true;
}