From db1db22818949ed112a7208b6063b208952e95ea Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 1 Oct 2014 10:10:49 +0200 Subject: 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 --- src/corelib/tools/qvector.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/corelib/tools/qvector.h') 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::operator==(const QVector &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; } -- cgit v1.2.3