diff --git a/dbms/src/Common/memcmpSmall.h b/dbms/src/Common/memcmpSmall.h index 8d69209b4ef..5dc5e04a707 100644 --- a/dbms/src/Common/memcmpSmall.h +++ b/dbms/src/Common/memcmpSmall.h @@ -5,13 +5,6 @@ #include -/// We can process uninitialized memory in the functions below. -/// Results don't depend on the values inside uninitialized memory but Memory Sanitizer cannot see it. -/// Disable optimized functions if compile with Memory Sanitizer. - -#if defined(__SSE2__) && !defined(MEMORY_SANITIZER) -#include - namespace detail { @@ -28,6 +21,15 @@ inline int cmp(T a, T b) } + +/// We can process uninitialized memory in the functions below. +/// Results don't depend on the values inside uninitialized memory but Memory Sanitizer cannot see it. +/// Disable optimized functions if compile with Memory Sanitizer. + +#if defined(__SSE2__) && !defined(MEMORY_SANITIZER) +#include + + /** All functions works under the following assumptions: * - it's possible to read up to 15 excessive bytes after end of 'a' and 'b' region; * - memory regions are relatively small and extra loop unrolling is not worth to do. @@ -198,7 +200,10 @@ inline bool memoryIsZeroSmallAllowOverflow15(const void * data, size_t size) template inline int memcmpSmallAllowOverflow15(const Char * a, size_t a_size, const Char * b, size_t b_size) { - return memcmp(a, b, std::min(a_size, b_size)); + if (auto res = memcmp(a, b, std::min(a_size, b_size))) + return res; + else + return detail::cmp(a_size, b_size); } template