From 65ae717b2c8fc979ccb30c967335999a6d90eb4f Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 16 Mar 2011 17:02:56 +0100 Subject: corelib/tools: Add two ### Qt 5 comments A proposol to speed up qHash(QString) and QVector. --- src/corelib/tools/qhash.cpp | 4 ++++ src/corelib/tools/qvector.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 66ec660..b6ba8b2 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -54,6 +54,10 @@ QT_BEGIN_NAMESPACE + +// ### Qt 5: see tests/benchmarks/corelib/tools/qhash/qhash_string.cpp +// Hashing of the whole string is a waste of cycles. + /* These functions are based on Peter J. Weinberger's hash function (from the Dragon Book). The constant 24 in the original function diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 56d1cca..9418642 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -115,6 +115,8 @@ class QVector }; public: + // ### Qt 5: Consider making QVector non-shared to get at least one + // "really fast" container. See tests/benchmarks/corelib/tools/qvector/ inline QVector() : d(&QVectorData::shared_null) { d->ref.ref(); } explicit QVector(int size); QVector(int size, const T &t); -- cgit v0.12