]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/third-party/folly/folly/hash/Hash.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
14 * Thomas Wang 64 bit mix hash function
17 inline uint64_t twang_mix64(uint64_t key
) noexcept
{
18 key
= (~key
) + (key
<< 21); // key *= (1 << 21) - 1; key -= 1;
19 key
= key
^ (key
>> 24);
20 key
= key
+ (key
<< 3) + (key
<< 8); // key *= 1 + (1 << 3) + (1 << 8)
21 key
= key
^ (key
>> 14);
22 key
= key
+ (key
<< 2) + (key
<< 4); // key *= 1 + (1 << 2) + (1 << 4)
23 key
= key
^ (key
>> 28);
24 key
= key
+ (key
<< 31); // key *= 1 + (1 << 31)