diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-01-31 12:11:54 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-04-09 20:03:25 +0200 |
commit | c6cdf38e752c22babdbe645366bdfb7ce51d01ff (patch) | |
tree | 450b02523cb5a16791674ad1d06fb68c72eac971 /src/corelib/itemmodels/qabstractitemmodel.h | |
parent | 775945137b6ef62de9a7d416b1fe59d79006ba82 (diff) | |
download | qtbase-c6cdf38e752c22babdbe645366bdfb7ce51d01ff.tar.gz |
Change qHash() to work with size_t instead of uint
This is required, so that QHash and QSet can hold more
than 2^32 items on 64 bit platforms.
The actual hashing functions for strings are still 32bit, this will
be changed in a follow-up commit.
Change-Id: I4372125252486075ff3a0b45ecfa818359fe103b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/itemmodels/qabstractitemmodel.h')
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 2cc1bd8ce6..86ff361ccb 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -103,7 +103,7 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &); class QPersistentModelIndexData; // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) -uint qHash(const QPersistentModelIndex &index, uint seed = 0) noexcept; +size_t qHash(const QPersistentModelIndex &index, size_t seed = 0) noexcept; class Q_CORE_EXPORT QPersistentModelIndex { @@ -141,14 +141,14 @@ public: bool isValid() const; private: QPersistentModelIndexData *d; - friend uint qHash(const QPersistentModelIndex &, uint seed) noexcept; + friend size_t qHash(const QPersistentModelIndex &, size_t seed) noexcept; #ifndef QT_NO_DEBUG_STREAM friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &); #endif }; Q_DECLARE_SHARED(QPersistentModelIndex) -inline uint qHash(const QPersistentModelIndex &index, uint seed) noexcept +inline size_t qHash(const QPersistentModelIndex &index, size_t seed) noexcept { return qHash(index.d, seed); } @@ -461,8 +461,8 @@ inline QVariant QModelIndex::data(int arole) const inline Qt::ItemFlags QModelIndex::flags() const { return m ? m->flags(*this) : Qt::ItemFlags(); } -inline uint qHash(const QModelIndex &index) noexcept -{ return uint((uint(index.row()) << 4) + index.column() + index.internalId()); } +inline size_t qHash(const QModelIndex &index, size_t seed) noexcept +{ return size_t((size_t(index.row()) << 4) + size_t(index.column()) + index.internalId()) ^ seed; } QT_END_NAMESPACE |