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