summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-02-09 15:11:25 +0100
committerLars Knoll <lars.knoll@qt.io>2020-02-15 12:15:48 +0100
commit735fd68dacdf25e51691d2e804d5e9db643e7833 (patch)
treeec63a92e2e0db039872bfa85f13c669767a4f7b1 /tests/auto/gui
parentd4c8ad79c4d815b1a98f53f829aab38286d643bd (diff)
Implement better hash functions for integer types
The hash function provides rather good mixing of the input bits. It spreads numbers out evenly through the uint range, a change of one bit in the input changes around half the output bits, and it is pretty fast. Using this as a hash function over the simple hash(int) == int has the advantage that it reduces the amount of collisions for badly distributed keys. In addition, it allows us to always use power of two sizes for the hash table, leading to better performance for inserts and lookups. the 32 and 64 bit hash functions where chosen from https://nullprogram.com/blog/2018/07/31/. I selected the ones that give a very good distribution of the hash values while using the integer for both multiplication steps. This should be slighty faster than using two different numbers. While the result is still being cast to a uint, the method is prepared so it can handle 64 bit keys and seeds. Fixes: QTBUG-29009 Change-Id: Id7a1b97b3c0d219e65de2e6e1fe6faf092f8ce16 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/gui')
0 files changed, 0 insertions, 0 deletions