diff options
Diffstat (limited to 'src/corelib/tools/qhash.cpp')
-rw-r--r-- | src/corelib/tools/qhash.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index abec9ebb79..334bd52f1e 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -199,14 +199,14 @@ static uint crc32(...) } #endif -static inline uint hash(const uchar *p, int len, uint seed) Q_DECL_NOTHROW +static inline uint hash(const uchar *p, size_t len, uint seed) Q_DECL_NOTHROW { uint h = seed; if (hasFastCrc32()) - return crc32(p, size_t(len), h); + return crc32(p, len, h); - for (int i = 0; i < len; ++i) + for (size_t i = 0; i < len; ++i) h = 31 * h + p[i]; return h; @@ -217,14 +217,14 @@ uint qHashBits(const void *p, size_t len, uint seed) Q_DECL_NOTHROW return hash(static_cast<const uchar*>(p), int(len), seed); } -static inline uint hash(const QChar *p, int len, uint seed) Q_DECL_NOTHROW +static inline uint hash(const QChar *p, size_t len, uint seed) Q_DECL_NOTHROW { uint h = seed; if (hasFastCrc32()) - return crc32(p, size_t(len), h); + return crc32(p, len, h); - for (int i = 0; i < len; ++i) + for (size_t i = 0; i < len; ++i) h = 31 * h + p[i].unicode(); return h; @@ -232,23 +232,24 @@ static inline uint hash(const QChar *p, int len, uint seed) Q_DECL_NOTHROW uint qHash(const QByteArray &key, uint seed) Q_DECL_NOTHROW { - return hash(reinterpret_cast<const uchar *>(key.constData()), key.size(), seed); + return hash(reinterpret_cast<const uchar *>(key.constData()), size_t(key.size()), seed); } uint qHash(const QString &key, uint seed) Q_DECL_NOTHROW { - return hash(key.unicode(), key.size(), seed); + return hash(key.unicode(), size_t(key.size()), seed); } uint qHash(const QStringRef &key, uint seed) Q_DECL_NOTHROW { - return hash(key.unicode(), key.size(), seed); + return hash(key.unicode(), size_t(key.size()), seed); } uint qHash(const QBitArray &bitArray, uint seed) Q_DECL_NOTHROW { int m = bitArray.d.size() - 1; - uint result = hash(reinterpret_cast<const uchar *>(bitArray.d.constData()), qMax(0, m), seed); + uint result = hash(reinterpret_cast<const uchar *>(bitArray.d.constData()), + size_t(qMax(0, m)), seed); // deal with the last 0 to 7 bits manually, because we can't trust that // the padding is initialized to 0 in bitArray.d @@ -260,7 +261,7 @@ uint qHash(const QBitArray &bitArray, uint seed) Q_DECL_NOTHROW uint qHash(QLatin1String key, uint seed) Q_DECL_NOTHROW { - return hash(reinterpret_cast<const uchar *>(key.data()), key.size(), seed); + return hash(reinterpret_cast<const uchar *>(key.data()), size_t(key.size()), seed); } /*! @@ -324,7 +325,7 @@ static uint qt_create_qhash_seed() /* The QHash seed itself. */ -Q_CORE_EXPORT QBasicAtomicInt qt_qhash_seed = Q_BASIC_ATOMIC_INITIALIZER(-1); +static QBasicAtomicInt qt_qhash_seed = Q_BASIC_ATOMIC_INITIALIZER(-1); /*! \internal |