Use folly::popcount instead of rolling our own logic

This commit is contained in:
Marcus Holland-Moritz 2023-06-22 11:47:38 +02:00
parent 38cb73cb53
commit 2df28696b0

View File

@ -26,17 +26,15 @@
#include <memory>
#include <type_traits>
#include <folly/lang/Bits.h>
#include "dwarfs/compiler.h"
#define DWARFS_NILSIMSA_SIMILARITY(r, a, b) \
do { \
int bits = 0; \
for (int i = 0; i < 4; ++i) { \
if constexpr (std::is_same_v<unsigned long, uint64_t>) { \
bits += __builtin_popcountl(a[i] ^ b[i]); \
} else if constexpr (std::is_same_v<unsigned long long, uint64_t>) { \
bits += __builtin_popcountll(a[i] ^ b[i]); \
} \
bits += folly::popcount(a[i] ^ b[i]); \
} \
r 255 - bits; \
} while (false)