summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-08-18 20:30:55 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-08-28 09:53:03 +0200
commit2e3facf41971cc699b2ab9a62ff4da7654ba9497 (patch)
tree3611482b52df5985529ad0f5f5c244045bbf72ab /src
parentf563124eee7e0f58359599a8108ec0fde21477f4 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qvector.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index f26d61eb9c..cb4e193ffc 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -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>