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

This commit is contained in:
Ethan Rublee 2011-02-07 05:10:14 +00:00
parent 7b1c265563
commit 885cef7660

View File

@ -146,15 +146,15 @@ Hamming::ResultType Hamming::operator()(const unsigned char* a, const unsigned c
const size_t end = size - modulo;
for (i = 0; i < end; i += sizeof(pop_t))
{
size_t a2 = *reinterpret_cast<const pop_t*> (a + i);
size_t b2 = *reinterpret_cast<const pop_t*> (b + i);
pop_t a2 = *reinterpret_cast<const pop_t*> (a + i);
pop_t b2 = *reinterpret_cast<const pop_t*> (b + i);
result += __builtin_popcountl(a2 ^ b2);
}
if (modulo)
{
//in the case where size is not divisible by sizeof(size_t)
//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(&b2,b+end,modulo);
//std::cout << std::hex << (a2^b2) << std::endl;