Skip to content

Commit 38d0ab3

Browse files
committed
initialization cleanup.
1 parent a28e112 commit 38d0ab3

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

include/fast_float/float_common.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ struct alignas(16) value128 {
369369
constexpr value128(uint64_t _low, uint64_t _high) noexcept
370370
: low(_low), high(_high) {}
371371

372-
constexpr value128() noexcept = default;
372+
constexpr value128() noexcept : low(0), high(0) {}
373373
};
374374

375375
/* Helper C++14 constexpr generic implementation of leading_zeroes for 64-bit */
@@ -429,7 +429,7 @@ leading_zeroes(uint64_t input_num) noexcept {
429429

430430
/* Helper C++14 constexpr generic implementation of countr_zero for 32-bit */
431431
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 limb_t
432-
countr_zero_generic_32(uint32_t input_num) {
432+
countr_zero_generic_32(uint32_t input_num) noexcept {
433433
assert(input_num > 0);
434434
FASTFLOAT_ASSUME(input_num > 0);
435435
uint_fast16_t last_bit = 0;
@@ -457,7 +457,7 @@ countr_zero_generic_32(uint32_t input_num) {
457457

458458
/* count trailing zeroes for 32-bit integers */
459459
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 limb_t
460-
countr_zero_32(uint32_t input_num) {
460+
countr_zero_32(uint32_t input_num) noexcept {
461461
if (cpp20_and_in_constexpr()) {
462462
return countr_zero_generic_32(input_num);
463463
}
@@ -505,34 +505,35 @@ _umul128(uint64_t ab, uint64_t cd, uint64_t *hi) noexcept {
505505
// compute 64-bit a*b
506506
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128
507507
full_multiplication(uint64_t a, uint64_t b) noexcept {
508+
value128 answer;
508509
if (cpp20_and_in_constexpr()) {
509-
value128 answer;
510510
answer.low = umul128_generic(a, b, &answer.high);
511-
return answer;
512-
}
513-
value128 answer;
511+
} else {
514512
#if defined(_M_ARM64) && !defined(__MINGW32__)
515-
// ARM64 has native support for 64-bit multiplications, no need to emulate
516-
// But MinGW on ARM64 doesn't have native support for 64-bit multiplications
517-
answer.high = __umulh(a, b);
518-
answer.low = a * b;
513+
// ARM64 has native support for 64-bit multiplications, no need to emulate
514+
// But MinGW on ARM64 doesn't have native support for 64-bit multiplications
515+
answer.high = __umulh(a, b);
516+
answer.low = a * b;
519517
#elif defined(FASTFLOAT_32BIT) || (defined(_WIN64) && !defined(__clang__) && \
520518
!defined(_M_ARM64) && !defined(__GNUC__))
521-
answer.low = _umul128(a, b, &answer.high); // _umul128 not available on ARM64
519+
answer.low =
520+
_umul128(a, b, &answer.high); // _umul128 not available on ARM64
522521
#elif defined(FASTFLOAT_64BIT) && defined(__SIZEOF_INT128__)
523-
__uint128_t r = ((__uint128_t)a) * b;
524-
answer.low = uint64_t(r);
525-
answer.high = uint64_t(r >> 64);
522+
__uint128_t r = (static_cast<__uint128_t>(a)) * b;
523+
answer.low = static_cast<uint64_t>(r);
524+
answer.high = static_cast<uint64_t>(r >> 64);
526525
#else
527-
answer.low = umul128_generic(a, b, &answer.high);
526+
answer.low = umul128_generic(a, b, &answer.high);
528527
#endif
528+
}
529529
return answer;
530530
}
531531

532532
struct alignas(16) adjusted_mantissa {
533533
am_mant_t mantissa;
534534
am_pow_t power2;
535-
adjusted_mantissa() noexcept {};
535+
536+
constexpr adjusted_mantissa() noexcept : mantissa(0), power2(0) {}
536537

537538
constexpr bool operator==(adjusted_mantissa const &o) const noexcept {
538539
return mantissa == o.mantissa && power2 == o.power2;

0 commit comments

Comments
 (0)