Micro-optimize QVector::count()

...by instantiating std::count() not with QVector::const_iterator, which is a
class, but with const T*, thus increasing the chance that the instantiation
can be shared with other instantiations in the executable. It might also enable
STL implementations to choose a hand-optimized version of the algorithm for C++
builtin types.

Change-Id: I93df4e58f76838d98b565f229c19e317774b7b4c
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2014-08-18 20:30:55 +02:00
parent f563124eee
commit 2e3facf419

View File

@ -810,7 +810,9 @@ bool QVector<T>::contains(const T &t) const
template <typename T>
int QVector<T>::count(const T &t) const
{
return int(std::count(cbegin(), cend(), t));
const T *b = d->begin();
const T *e = d->end();
return int(std::count(b, e, t));
}
template <typename T>