From 397df4a549b3117938bec8ad7ca13c727cbdcfb8 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 25 Jul 2013 15:12:44 +0200 Subject: [PATCH] adjust to qHash(QString) returning a full int's worth of bits in qt5 Change-Id: I3f9357a2affa63cc50c6fc20b61d7ea4323a6cfb Reviewed-by: hjk Reviewed-by: Oswald Buddenhagen --- src/linguist/lupdate/cpp.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/linguist/lupdate/cpp.cpp b/src/linguist/lupdate/cpp.cpp index ec02be1..7418689 100644 --- a/src/linguist/lupdate/cpp.cpp +++ b/src/linguist/lupdate/cpp.cpp @@ -79,16 +79,14 @@ public: bool operator==(const HashString &other) const { return m_str == other.m_str; } private: QString m_str; - // qHash() of a QString is only 28 bits wide, so we can use - // the highest bit(s) as the "hash valid" flag. - mutable uint m_hash; + mutable uint m_hash; // We use the highest bit as a validity indicator (set => invalid) friend uint qHash(const HashString &str); }; uint qHash(const HashString &str) { if (str.m_hash & 0x80000000) - str.m_hash = qHash(str.m_str); + str.m_hash = qHash(str.m_str) & 0x7fffffff; return str.m_hash; } @@ -99,7 +97,7 @@ public: bool operator==(const HashStringList &other) const { return m_list == other.m_list; } private: QList m_list; - mutable uint m_hash; + mutable uint m_hash; // We use the highest bit as a validity indicator (set => invalid) friend uint qHash(const HashStringList &list); }; @@ -108,8 +106,8 @@ uint qHash(const HashStringList &list) if (list.m_hash & 0x80000000) { uint hash = 0; foreach (const HashString &qs, list.m_list) { - hash ^= qHash(qs) ^ 0x0ad9f526; - hash = ((hash << 13) & 0x0fffffff) | (hash >> 15); + hash ^= qHash(qs) ^ 0x6ad9f526; + hash = ((hash << 13) & 0x7fffffff) | (hash >> 18); } list.m_hash = hash; } -- 2.7.4