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:28 +0200 |
commit | 023e6bd937a991ab3172f4d47fd89cf01d3bd95c (patch) | |
tree | 52653b24b9efa10e1026c6dba8c2caf069272830 /src/corelib/tools | |
parent | 4adf5e1a9ef4fe78f4b70b7462943246903f4f11 (diff) |
Prepare QVector::contains() for sharing with QList::contains()
...by implementing it via std::find().
This might also enable STL implementations to choose a
hand-optimized version of the algorithm for C++ builtin types.
Change-Id: I86e94d63ff58332f2fa6eafb3c1baccd125a6f34
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qvector.h | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 8b0804e5df..ab48ae5ea3 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -791,12 +791,9 @@ int QVector<T>::lastIndexOf(const T &t, int from) const template <typename T> bool QVector<T>::contains(const T &t) const { - T* i = d->begin(); - T* e = d->end(); - for (; i != e; ++i) - if (*i == t) - return true; - return false; + const T *b = d->begin(); + const T *e = d->end(); + return std::find(b, e, t) != e; } template <typename T> |