Don't initialize the first parameter of _BitScanReverse* functions

Like the document example, no need to initialize `r` to 0.
https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanreverse-bitscanreverse64
This commit is contained in:
Ma Lin
2021-09-25 16:36:53 +08:00
parent cc22042da0
commit 95f492ea17
11 changed files with 21 additions and 30 deletions
+4 -6
View File
@@ -159,9 +159,8 @@ static unsigned ZDICT_NbCommonBytes (size_t val)
} else { /* Big Endian CPU */
if (MEM_64bits()) {
# if defined(_MSC_VER) && defined(_WIN64)
unsigned long r = 0;
_BitScanReverse64( &r, val );
return (unsigned)(r>>3);
unsigned long r;
return _BitScanReverse64(&r, val) ? (unsigned)(r >> 3) : 0;
# elif defined(__GNUC__) && (__GNUC__ >= 3)
return (unsigned)(__builtin_clzll(val) >> 3);
# else
@@ -174,9 +173,8 @@ static unsigned ZDICT_NbCommonBytes (size_t val)
# endif
} else { /* 32 bits */
# if defined(_MSC_VER)
unsigned long r = 0;
_BitScanReverse( &r, (unsigned long)val );
return (unsigned)(r>>3);
unsigned long r;
return _BitScanReverse(&r, (unsigned long)val) ? (unsigned)(r >> 3) : 0;
# elif defined(__GNUC__) && (__GNUC__ >= 3)
return (unsigned)(__builtin_clz((U32)val) >> 3);
# else