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>
This commit is contained in:
parent
5e01d3f642
commit
db1db22818
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user