mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-02-08 18:56:45 +08:00
initialization cleanup.
This commit is contained in:
parent
5857b98bfd
commit
a28e112d8f
@ -258,16 +258,16 @@ enum class parse_error : uint_fast8_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename UC> struct parsed_number_string_t {
|
template <typename UC> struct parsed_number_string_t {
|
||||||
am_mant_t mantissa{0};
|
am_mant_t mantissa;
|
||||||
|
|
||||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
bool negative{false};
|
bool negative;
|
||||||
#endif
|
#endif
|
||||||
bool invalid{false}; // be optimistic
|
bool invalid;
|
||||||
bool too_many_digits{false}; // be optimistic
|
bool too_many_digits;
|
||||||
parse_error error{parse_error::no_error}; // be optimistic
|
parse_error error;
|
||||||
|
|
||||||
am_pow_t exponent{0};
|
am_pow_t exponent;
|
||||||
|
|
||||||
// contains the range of the significant digits
|
// contains the range of the significant digits
|
||||||
span<UC const> integer; // non-nullable
|
span<UC const> integer; // non-nullable
|
||||||
@ -294,7 +294,7 @@ template <bool basic_json_fmt, typename UC>
|
|||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t<UC>
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t<UC>
|
||||||
parse_number_string(UC const *p, UC const *pend,
|
parse_number_string(UC const *p, UC const *pend,
|
||||||
parse_options_t<UC> const options) noexcept {
|
parse_options_t<UC> const options) noexcept {
|
||||||
parsed_number_string_t<UC> answer;
|
parsed_number_string_t<UC> answer{};
|
||||||
// so dereference without checks
|
// so dereference without checks
|
||||||
FASTFLOAT_ASSUME(p < pend);
|
FASTFLOAT_ASSUME(p < pend);
|
||||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
@ -514,8 +514,8 @@ parse_number_string(UC const *p, UC const *pend,
|
|||||||
}
|
}
|
||||||
answer.exponent = am_pow_t(answer.fraction.ptr - p) + exp_number;
|
answer.exponent = am_pow_t(answer.fraction.ptr - p) + exp_number;
|
||||||
}
|
}
|
||||||
|
// We now corrected both exponent and mantissa, to a truncated value
|
||||||
}
|
}
|
||||||
// We have now corrected both exponent and mantissa, to a truncated value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return answer;
|
return answer;
|
||||||
|
|||||||
@ -347,17 +347,16 @@ fastfloat_strncasecmp(UC const *actual_mixedcase, UC const *expected_lowercase,
|
|||||||
// a pointer and a length to a contiguous block of memory
|
// a pointer and a length to a contiguous block of memory
|
||||||
template <typename T> struct span {
|
template <typename T> struct span {
|
||||||
T const *ptr;
|
T const *ptr;
|
||||||
uint_fast16_t length;
|
am_digits length;
|
||||||
|
|
||||||
constexpr span(T const *_ptr, uint_fast16_t _length) noexcept
|
constexpr span(T const *_ptr, am_digits _length) noexcept
|
||||||
: ptr(_ptr), length(_length) {}
|
: ptr(_ptr), length(_length) {}
|
||||||
|
|
||||||
constexpr span() noexcept : ptr(nullptr), length(0) {}
|
constexpr span() noexcept = default;
|
||||||
|
|
||||||
constexpr uint_fast16_t len() const noexcept { return length; }
|
constexpr am_digits len() const noexcept { return length; }
|
||||||
|
|
||||||
FASTFLOAT_CONSTEXPR14 const T &
|
FASTFLOAT_CONSTEXPR14 const T &operator[](am_digits index) const noexcept {
|
||||||
operator[](uint_fast16_t index) const noexcept {
|
|
||||||
FASTFLOAT_DEBUG_ASSERT(index < length);
|
FASTFLOAT_DEBUG_ASSERT(index < length);
|
||||||
return ptr[index];
|
return ptr[index];
|
||||||
}
|
}
|
||||||
@ -370,7 +369,7 @@ struct alignas(16) value128 {
|
|||||||
constexpr value128(uint64_t _low, uint64_t _high) noexcept
|
constexpr value128(uint64_t _low, uint64_t _high) noexcept
|
||||||
: low(_low), high(_high) {}
|
: low(_low), high(_high) {}
|
||||||
|
|
||||||
constexpr value128() noexcept {}
|
constexpr value128() noexcept = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Helper C++14 constexpr generic implementation of leading_zeroes for 64-bit */
|
/* Helper C++14 constexpr generic implementation of leading_zeroes for 64-bit */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user