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>
This commit is contained in:
Marc Mutz 2014-08-18 20:30:55 +02:00 committed by Giuseppe D'Angelo
parent 4adf5e1a9e
commit 023e6bd937

View File

@ -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>