File tree Expand file tree Collapse file tree
include/bitcoin/system/impl/hash Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -236,9 +236,31 @@ INLINE constexpr size_t djb2_hash(const data_slice& data) NOEXCEPT
236236 return hash;
237237}
238238
239- // Combine hash values, such as a pair of djb2_hash outputs.
239+ // Formerly: return left ^ shift_left(right, one);
240+ // Combine hash values, such as djb2_hash or unique_hash outputs.
240241INLINE constexpr size_t hash_combine (size_t left, size_t right) NOEXCEPT
241242{
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;
242264 return left ^ shift_left (right, one);
243265}
244266
Original file line number Diff line number Diff line change @@ -427,6 +427,16 @@ BOOST_AUTO_TEST_CASE(functions__hash_combine__same_values__expected)
427427 {
428428 BOOST_REQUIRE_EQUAL (hash, 4893418499_u64);
429429 }
430+
431+ // Complex hash.
432+ // //if constexpr (sizeof(size_t) == sizeof(uint32_t))
433+ // //{
434+ // // BOOST_REQUIRE_EQUAL(hash, 3172851131_u32);
435+ // //}
436+ // //else
437+ // //{
438+ // // BOOST_REQUIRE_EQUAL(hash, 6326001304333978798_u64);
439+ // //}
430440}
431441
432442BOOST_AUTO_TEST_SUITE_END ()
You can’t perform that action at this time.
0 commit comments