Refactor code a little bit more.

This commit is contained in:
Nikolai Kochetov 2020-12-21 17:30:17 +03:00
parent 29e0b4ec40
commit 78429eca70

View File

@ -104,6 +104,21 @@ struct Hash
crc2 = _mm_crc32_u32(crc2, hashes[i]);
#else
throw Exception("hashSum is not implemented without sse4.2 support", ErrorCodes::NOT_IMPLEMENTED);
#endif
return crc1 | (crc2 << 32u);
}
static ALWAYS_INLINE inline UInt64 hashSum(const UInt64 * hashes, size_t K)
{
UInt64 crc1 = -1ULL;
UInt64 crc2 = -1ULL;
#ifdef __SSE4_2__
for (size_t i = 0; i < K; i += 2)
crc1 = _mm_crc32_u64(crc1, hashes[i]);
for (size_t i = 1; i < K; i += 2)
crc2 = _mm_crc32_u64(crc2, hashes[i]);
#else
throw Exception("hashSum is not implemented without sse4.2 support", ErrorCodes::NOT_IMPLEMENTED);
#endif
return crc1 | (crc2 << 32u);
}