diff options
Diffstat (limited to 'src/corelib/tools/qlist.h')
-rw-r--r-- | src/corelib/tools/qlist.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 326a276f40..9704c7b953 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -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; } @@ -922,9 +921,9 @@ Q_OUTOFLINE_TEMPLATE int QList<T>::lastIndexOf(const T &t, int from) const template <typename T> Q_OUTOFLINE_TEMPLATE bool QList<T>::contains(const T &t) const { - Node *b = reinterpret_cast<Node *>(p.begin()); - Node *i = reinterpret_cast<Node *>(p.end()); - while (i-- != b) + Node *e = reinterpret_cast<Node *>(p.end()); + Node *i = reinterpret_cast<Node *>(p.begin()); + for (; i != e; ++i) if (i->t() == t) return true; return false; @@ -934,9 +933,9 @@ template <typename T> Q_OUTOFLINE_TEMPLATE int QList<T>::count(const T &t) const { int c = 0; - Node *b = reinterpret_cast<Node *>(p.begin()); - Node *i = reinterpret_cast<Node *>(p.end()); - while (i-- != b) + Node *e = reinterpret_cast<Node *>(p.end()); + Node *i = reinterpret_cast<Node *>(p.begin()); + for (; i != e; ++i) if (i->t() == t) ++c; return c; |