diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index b56afe15c2..9704c7b953 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -921,9 +921,9 @@ Q_OUTOFLINE_TEMPLATE int QList::lastIndexOf(const T &t, int from) const template Q_OUTOFLINE_TEMPLATE bool QList::contains(const T &t) const { - Node *b = reinterpret_cast(p.begin()); - Node *i = reinterpret_cast(p.end()); - while (i-- != b) + Node *e = reinterpret_cast(p.end()); + Node *i = reinterpret_cast(p.begin()); + for (; i != e; ++i) if (i->t() == t) return true; return false; @@ -933,9 +933,9 @@ template Q_OUTOFLINE_TEMPLATE int QList::count(const T &t) const { int c = 0; - Node *b = reinterpret_cast(p.begin()); - Node *i = reinterpret_cast(p.end()); - while (i-- != b) + Node *e = reinterpret_cast(p.end()); + Node *i = reinterpret_cast(p.begin()); + for (; i != e; ++i) if (i->t() == t) ++c; return c;