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/time | |
parent | 775945137b6ef62de9a7d416b1fe59d79006ba82 (diff) |
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/time')
-rw-r--r-- | src/corelib/time/qcalendar.cpp | 2 | ||||
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 12 | ||||
-rw-r--r-- | src/corelib/time/qdatetime.h | 6 |
3 files changed, 10 insertions, 10 deletions
diff --git a/src/corelib/time/qcalendar.cpp b/src/corelib/time/qcalendar.cpp index 02788f5e23..7b50eb008c 100644 --- a/src/corelib/time/qcalendar.cpp +++ b/src/corelib/time/qcalendar.cpp @@ -61,7 +61,7 @@ inline bool operator==(const CalendarName &u, const CalendarName &v) return u.compare(v, Qt::CaseInsensitive) == 0; } -inline uint qHash(const CalendarName &key, uint seed = 0) noexcept +inline size_t qHash(const CalendarName &key, size_t seed = 0) noexcept { return qHash(key.toLower(), seed); } diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 5cd410c0b0..15654117a9 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -5950,13 +5950,13 @@ QDebug operator<<(QDebug dbg, const QDateTime &date) } #endif // debug_stream && datestring -/*! \fn uint qHash(const QDateTime &key, uint seed = 0) +/*! \fn size_t qHash(const QDateTime &key, size_t seed = 0) \relates QHash \since 5.0 Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(const QDateTime &key, uint seed) +size_t qHash(const QDateTime &key, size_t seed) { // Use to toMSecsSinceEpoch instead of individual qHash functions for // QDate/QTime/spec/offset because QDateTime::operator== converts both arguments @@ -5965,24 +5965,24 @@ uint qHash(const QDateTime &key, uint seed) return key.isValid() ? qHash(key.toMSecsSinceEpoch(), seed) : seed; } -/*! \fn uint qHash(QDate key, uint seed = 0) +/*! \fn size_t qHash(QDate key, size_t seed = 0) \relates QHash \since 5.0 Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(QDate key, uint seed) noexcept +size_t qHash(QDate key, size_t seed) noexcept { return qHash(key.toJulianDay(), seed); } -/*! \fn uint qHash(QTime key, uint seed = 0) +/*! \fn size_t qHash(QTime key, size_t seed = 0) \relates QHash \since 5.0 Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(QTime key, uint seed) noexcept +size_t qHash(QTime key, size_t seed) noexcept { return qHash(key.msecsSinceStartOfDay(), seed); } diff --git a/src/corelib/time/qdatetime.h b/src/corelib/time/qdatetime.h index b1a3e0b1d6..52524f70a4 100644 --- a/src/corelib/time/qdatetime.h +++ b/src/corelib/time/qdatetime.h @@ -447,9 +447,9 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &); // QDateTime is not noexcept for now -- to be revised once // timezone and calendaring support is added -Q_CORE_EXPORT uint qHash(const QDateTime &key, uint seed = 0); -Q_CORE_EXPORT uint qHash(QDate key, uint seed = 0) noexcept; -Q_CORE_EXPORT uint qHash(QTime key, uint seed = 0) noexcept; +Q_CORE_EXPORT size_t qHash(const QDateTime &key, size_t seed = 0); +Q_CORE_EXPORT size_t qHash(QDate key, size_t seed = 0) noexcept; +Q_CORE_EXPORT size_t qHash(QTime key, size_t seed = 0) noexcept; QT_END_NAMESPACE |