mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-14 23:05:33 -04:00
Use folly::popcount instead of rolling our own logic
This commit is contained in:
parent
38cb73cb53
commit
2df28696b0
@ -26,17 +26,15 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include <folly/lang/Bits.h>
|
||||||
|
|
||||||
#include "dwarfs/compiler.h"
|
#include "dwarfs/compiler.h"
|
||||||
|
|
||||||
#define DWARFS_NILSIMSA_SIMILARITY(r, a, b) \
|
#define DWARFS_NILSIMSA_SIMILARITY(r, a, b) \
|
||||||
do { \
|
do { \
|
||||||
int bits = 0; \
|
int bits = 0; \
|
||||||
for (int i = 0; i < 4; ++i) { \
|
for (int i = 0; i < 4; ++i) { \
|
||||||
if constexpr (std::is_same_v<unsigned long, uint64_t>) { \
|
bits += folly::popcount(a[i] ^ b[i]); \
|
||||||
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]); \
|
|
||||||
} \
|
|
||||||
} \
|
} \
|
||||||
r 255 - bits; \
|
r 255 - bits; \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user