From c27784c065676149fb6fdcad10ac594c06cfef05 Mon Sep 17 00:00:00 2001 From: stickz Date: Fri, 5 Jul 2024 01:50:35 -0400 Subject: [PATCH] fixes --- libtorrent/rak/algorithm.h | 5 ----- libtorrent/src/torrent/bitfield.cc | 12 ++++-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/libtorrent/rak/algorithm.h b/libtorrent/rak/algorithm.h index e999101e..3342f2bb 100644 --- a/libtorrent/rak/algorithm.h +++ b/libtorrent/rak/algorithm.h @@ -293,11 +293,6 @@ make_base(_InputIter __first, _InputIter __last, _Ftor __ftor) { return __base; } -#if USE_AVX2_POPCOUNT -inline uint32_t popcount_wrapper_avx2(uint8_t* data) { - return popcnt_AVX2_lookup(data, sizeof(data)); -} -#endif template inline int popcount_wrapper(T t) { #if USE_BUILTIN_POPCOUNT diff --git a/libtorrent/src/torrent/bitfield.cc b/libtorrent/src/torrent/bitfield.cc index df4be99c..5f29d035 100644 --- a/libtorrent/src/torrent/bitfield.cc +++ b/libtorrent/src/torrent/bitfield.cc @@ -88,27 +88,23 @@ Bitfield::update() { // Clears the unused bits. clear_tail(); + #if USE_AVX2_POPCOUNT + m_set = rak::popcnt_AVX2_lookup(m_data, size_bytes()); + #else m_set = 0; iterator itr = m_data; iterator last = end(); while (itr + sizeof(unsigned int) <= last) { - #if USE_AVX2_POPCOUNT - m_set += rak::popcount_wrapper_avx2(reinterpret_cast(itr)); - #else m_set += rak::popcount_wrapper(*reinterpret_cast(itr)); - #endif itr += sizeof(unsigned int); } while (itr != last) { - #if USE_AVX2_POPCOUNT - m_set += rak::popcount_wrapper_avx2(reinterpret_cast(itr++)); - #else m_set += rak::popcount_wrapper(*itr++); - #endif } + #endif } void