diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-08-18 20:30:55 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2014-10-03 13:31:38 +0200 |
commit | c6752c5aa19c4aa7ef2193878063f44d979b1cf6 (patch) | |
tree | fc56281f8713eccf80bd445ccf8c2118b2278107 /src/corelib/tools/qvector.h | |
parent | 023e6bd937a991ab3172f4d47fd89cf01d3bd95c (diff) |
Prepare QVector::operator==() for sharing with QList::operator==()
...by implementing it via std::equal().
This might also enable STL implementations to choose a
hand-optimized version of the algorithm for C++ builtin types.
Change-Id: I1347a7f365b3d2947f19a81b95aa8d89b8ad303d
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r-- | src/corelib/tools/qvector.h | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index ab48ae5ea3..bfc7f2380f 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -707,13 +707,10 @@ bool QVector<T>::operator==(const QVector<T> &v) const return true; if (d->size != v.d->size) return false; - 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; + const T *vb = v.d->begin(); + const T *b = d->begin(); + const T *e = d->end(); + return std::equal(b, e, vb); } template <typename T> |