From 023e6bd937a991ab3172f4d47fd89cf01d3bd95c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 18 Aug 2014 20:30:55 +0200 Subject: 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 --- src/corelib/tools/qvector.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/corelib/tools/qvector.h') 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::lastIndexOf(const T &t, int from) const template bool QVector::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 -- cgit v1.2.3