QList: 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: I31be6ad2b6d78ccce7e8a8f8f8b9e0af62f7471b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
9618fb7262
commit
b1482795ee
|
|
@ -770,11 +770,10 @@ Q_OUTOFLINE_TEMPLATE bool QList<T>::operator==(const QList<T> &l) const
|
|||
return true;
|
||||
if (p.size() != l.p.size())
|
||||
return false;
|
||||
Node *i = reinterpret_cast<Node *>(p.end());
|
||||
Node *b = reinterpret_cast<Node *>(p.begin());
|
||||
Node *li = reinterpret_cast<Node *>(l.p.end());
|
||||
while (i != b) {
|
||||
--i; --li;
|
||||
Node *i = reinterpret_cast<Node *>(p.begin());
|
||||
Node *e = reinterpret_cast<Node *>(p.end());
|
||||
Node *li = reinterpret_cast<Node *>(l.p.begin());
|
||||
for (; i != e; ++i, ++li) {
|
||||
if (!(i->t() == li->t()))
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue