Skip to content

Commit 77c20c2

Browse files
committed
Comments on hash_combine.
1 parent 2eb9280 commit 77c20c2

1 file changed

Lines changed: 2 additions & 22 deletions

File tree

include/bitcoin/system/impl/hash/functions.ipp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -237,30 +237,10 @@ INLINE constexpr size_t djb2_hash(const data_slice& data) NOEXCEPT
237237
}
238238

239239
// Combine hash values, such as djb2_hash or unique_hash outputs.
240+
// Right should always be the lower entropy value (e.g. point index).
240241
INLINE constexpr size_t hash_combine(size_t left, size_t right) NOEXCEPT
241242
{
242-
//// This leads to mixing null points (850k identical) with other buckets.
243-
////constexpr auto prime1 = possible_narrow_cast<size_t>(0x9e3779b97f4a7c15_u64);
244-
////constexpr auto prime2 = possible_narrow_cast<size_t>(0x517cc1b727220a95_u64);
245-
////
246-
////auto first = left;
247-
////first ^= shift_right(first, 23);
248-
////first *= prime1;
249-
////first ^= shift_right(first, 19);
250-
////
251-
////auto second = right;
252-
////second ^= shift_right(second, 13);
253-
////second *= prime2;
254-
////second ^= shift_right(second, 31);
255-
////
256-
////// seed parameter, defaults to zero.
257-
////first ^= second;
258-
////first += seed;
259-
////first ^= shift_right(first, 17);
260-
////first *= prime1;
261-
////first ^= shift_right(first, 29);
262-
263-
////return first;
243+
// Shift ensures left == right does not always return zero.
264244
return bit_xor(left, shift_left(right));
265245
}
266246

0 commit comments

Comments
 (0)