@@ -9,14 +9,6 @@ namespace eosio::chain {
99
1010namespace detail {
1111
12- #if __cplusplus >= 202002L
13- inline int popcount (uint64_t x) noexcept { return std::popcount (x); }
14- inline uint64_t bit_floor (uint64_t x) noexcept { return std::bit_floor (x); }
15- #else
16- inline int popcount (uint64_t x) noexcept { return __builtin_popcountll (x); }
17- inline uint64_t bit_floor (uint64_t x) noexcept { return x == 0 ? 0ull : 1ull << (64 - 1 - __builtin_clzll (x)); }
18- #endif
19-
2012inline digest_type hash_combine (const digest_type& a, const digest_type& b) {
2113 return digest_type::hash (std::make_pair (std::cref (a), std::cref (b)));
2214}
@@ -26,7 +18,7 @@ requires std::is_same_v<std::decay_t<typename std::iterator_traits<It>::value_ty
2618inline digest_type calculate_merkle_pow2 (const It& start, const It& end) {
2719 assert (end >= start + 2 );
2820 auto size = static_cast <size_t >(end - start);
29- assert (detail ::bit_floor (size) == size);
21+ assert (std ::bit_floor (size) == size);
3022
3123 if (size == 2 )
3224 return hash_combine (start[0 ], start[1 ]);
@@ -76,17 +68,15 @@ inline digest_type calculate_merkle_pow2(const It& start, const It& end) {
7668// appended (or 0.25% of default 2MB thread stack size on Ubuntu).
7769// ------------------------------------------------------------------------
7870template <class It >
79- #if __cplusplus >= 202002L
8071requires std::random_access_iterator<It> &&
8172 std::is_same_v<std::decay_t <typename std::iterator_traits<It>::value_type>, digest_type>
82- #endif
8373inline digest_type calculate_merkle (const It& start, const It& end) {
8474 assert (end >= start);
8575 auto size = static_cast <size_t >(end - start);
8676 if (size <= 1 )
8777 return (size == 0 ) ? digest_type{} : *start;
8878
89- auto midpoint = detail ::bit_floor (size);
79+ auto midpoint = std ::bit_floor (size);
9080 if (size == midpoint)
9181 return detail::calculate_merkle_pow2<It, true >(start, end);
9282
@@ -102,10 +92,8 @@ inline digest_type calculate_merkle(const It& start, const It& end) {
10292// for the sequence of digests in the container.
10393// --------------------------------------------------------------------------
10494template <class Cont >
105- #if __cplusplus >= 202002L
10695requires std::random_access_iterator<decltype (Cont().begin())> &&
10796 std::is_same_v<std::decay_t <typename Cont::value_type>, digest_type>
108- #endif
10997inline digest_type calculate_merkle (const Cont& ids) {
11098 return calculate_merkle (ids.begin (), ids.end ()); // cbegin not supported for std::span until C++23.
11199}
0 commit comments