-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: remove all c style casts in minisketch subtree #57
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ template<typename I, int BITS, I MOD> NO_SANITIZE_MEMORY I MulWithClMulReduce(I | |
static constexpr I MASK = Mask<BITS, I>(); | ||
|
||
const __m128i MOD128 = _mm_cvtsi64_si128(MOD); | ||
__m128i product = _mm_clmulepi64_si128(_mm_cvtsi64_si128((uint64_t)a), _mm_cvtsi64_si128((uint64_t)b), 0x00); | ||
__m128i product = _mm_clmulepi64_si128(_mm_cvtsi64_si128(uint64_t(a)), _mm_cvtsi64_si128(uint64_t(b)), 0x00); | ||
if (BITS <= 32) { | ||
__m128i high1 = _mm_srli_epi64(product, BITS); | ||
__m128i red1 = _mm_clmulepi64_si128(high1, MOD128, 0x00); | ||
|
@@ -69,7 +69,7 @@ template<typename I, int BITS, int POS> NO_SANITIZE_MEMORY I MulTrinomial(I a, I | |
{ | ||
static constexpr I MASK = Mask<BITS, I>(); | ||
|
||
__m128i product = _mm_clmulepi64_si128(_mm_cvtsi64_si128((uint64_t)a), _mm_cvtsi64_si128((uint64_t)b), 0x00); | ||
__m128i product = _mm_clmulepi64_si128(_mm_cvtsi64_si128(uint64_t(a)), _mm_cvtsi64_si128(uint64_t(b)), 0x00); | ||
if (BITS <= 32) { | ||
__m128i high1 = _mm_srli_epi64(product, BITS); | ||
__m128i red1 = _mm_xor_si128(high1, _mm_slli_epi64(high1, POS)); | ||
|
@@ -92,7 +92,7 @@ template<typename I, int BITS, int POS> NO_SANITIZE_MEMORY I MulTrinomial(I a, I | |
return _mm_cvtsi128_si64(_mm_xor_si128(_mm_xor_si128(product, red1), red2)) & MASK; | ||
} | ||
} else { | ||
const __m128i MOD128 = _mm_cvtsi64_si128(1 + (((uint64_t)1) << POS)); | ||
const __m128i MOD128 = _mm_cvtsi64_si128(1 + ((uint64_t{1}) << POS)); | ||
__m128i red1 = _mm_clmulepi64_si128(high1, MOD128, 0x00); | ||
__m128i high2 = _mm_or_si128(_mm_srli_epi64(red1, BITS), _mm_srli_si128(_mm_slli_epi64(red1, 64 - BITS), 8)); | ||
__m128i red2 = _mm_xor_si128(high2, _mm_slli_epi64(high2, POS)); | ||
|
@@ -143,7 +143,7 @@ template<typename I, int B, I MOD, I (*MUL)(I, I), typename F, const F* SQR, con | |
Elem FromSeed(uint64_t seed) const { | ||
uint64_t k0 = 0x434c4d554c466c64ull; // "CLMULFld" | ||
uint64_t k1 = seed; | ||
uint64_t count = ((uint64_t)B) << 32; | ||
uint64_t count = (uint64_t(B)) << 32; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be |
||
I ret; | ||
do { | ||
ret = O::Mask(I(SipHash(k0, k1, count++))); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ std::vector<Minisketch> CreateSketches(uint32_t bits, size_t capacity) { | |
if (Minisketch::ImplementationSupported(bits, impl)) { | ||
CHECK(Minisketch::BitsSupported(bits)); | ||
ret.push_back(Minisketch(bits, impl, capacity)); | ||
CHECK((bool)ret.back()); | ||
CHECK(bool{ret.back()}); | ||
} else { | ||
// implementation 0 must always work unless field size is disabled | ||
CHECK(impl != 0 || !Minisketch::BitsSupported(bits)); | ||
|
@@ -274,7 +274,7 @@ int main(int argc, char** argv) { | |
try { | ||
test_complexity = 0; | ||
long long complexity = std::stoll(arg, &len); | ||
if (complexity >= 1 && len == arg.size() && ((uint64_t)complexity <= std::numeric_limits<uint64_t>::max() >> 10)) { | ||
if (complexity >= 1 && len == arg.size() && (static_cast<uint64_t>(complexity) <= std::numeric_limits<uint64_t>::max() >> 10)) { | ||
PastaPastaPasta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
test_complexity = complexity; | ||
} | ||
} catch (const std::logic_error&) {} | ||
|
@@ -289,7 +289,7 @@ int main(int argc, char** argv) { | |
#else | ||
const char* mode = ""; | ||
#endif | ||
printf("Running libminisketch tests%s with complexity=%llu\n", mode, (unsigned long long)test_complexity); | ||
printf("Running libminisketch tests%s with complexity=%llu\n", mode, static_cast<unsigned long long>(test_complexity)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use |
||
|
||
TestComputeFunctions(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all of these can be
uint64_t{a}
etc.