Commit 885cef76 authored by Ethan Rublee's avatar Ethan Rublee

Minor fix to pop count based hamming distance. Being consistent with type.

parent 7b1c2655
...@@ -146,15 +146,15 @@ Hamming::ResultType Hamming::operator()(const unsigned char* a, const unsigned c ...@@ -146,15 +146,15 @@ Hamming::ResultType Hamming::operator()(const unsigned char* a, const unsigned c
const size_t end = size - modulo; const size_t end = size - modulo;
for (i = 0; i < end; i += sizeof(pop_t)) for (i = 0; i < end; i += sizeof(pop_t))
{ {
size_t a2 = *reinterpret_cast<const pop_t*> (a + i); pop_t a2 = *reinterpret_cast<const pop_t*> (a + i);
size_t b2 = *reinterpret_cast<const pop_t*> (b + i); pop_t b2 = *reinterpret_cast<const pop_t*> (b + i);
result += __builtin_popcountl(a2 ^ b2); result += __builtin_popcountl(a2 ^ b2);
} }
if (modulo) if (modulo)
{ {
//in the case where size is not divisible by sizeof(size_t) //in the case where size is not divisible by sizeof(size_t)
//need to mask of the bits at the end //need to mask of the bits at the end
size_t a2=0,b2=0; pop_t a2=0,b2=0;
memcpy(&a2,a+end,modulo); memcpy(&a2,a+end,modulo);
memcpy(&b2,b+end,modulo); memcpy(&b2,b+end,modulo);
//std::cout << std::hex << (a2^b2) << std::endl; //std::cout << std::hex << (a2^b2) << std::endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment