Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stickz committed Jul 5, 2024
1 parent 6cafba1 commit c27784c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
5 changes: 0 additions & 5 deletions libtorrent/rak/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
inline int popcount_wrapper(T t) {
#if USE_BUILTIN_POPCOUNT
Expand Down
12 changes: 4 additions & 8 deletions libtorrent/src/torrent/bitfield.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t*>(itr));
#else
m_set += rak::popcount_wrapper(*reinterpret_cast<unsigned int*>(itr));
#endif
itr += sizeof(unsigned int);
}

while (itr != last) {
#if USE_AVX2_POPCOUNT
m_set += rak::popcount_wrapper_avx2(reinterpret_cast<uint8_t*>(itr++));
#else
m_set += rak::popcount_wrapper(*itr++);
#endif
}
#endif
}

void
Expand Down

0 comments on commit c27784c

Please sign in to comment.