mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
reduce register pressure.
This commit is contained in:
parent
9688b3bdf7
commit
1e3a135b8d
@ -1,6 +1,9 @@
|
|||||||
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
|
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
|
||||||
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com
|
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com
|
||||||
|
|
||||||
|
|
||||||
|
//#define FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
|
|
||||||
#if defined(__linux__) || (__APPLE__ && __aarch64__)
|
#if defined(__linux__) || (__APPLE__ && __aarch64__)
|
||||||
#define USING_COUNTERS
|
#define USING_COUNTERS
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -223,8 +223,8 @@ is_truncated(span<UC const> s) noexcept {
|
|||||||
|
|
||||||
template <typename UC>
|
template <typename UC>
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void
|
||||||
parse_eight_digits(UC const *&p, limb &value, size_t &counter,
|
parse_eight_digits(UC const *&p, limb &value, unsigned int &counter,
|
||||||
size_t &count) noexcept {
|
unsigned int &count) noexcept {
|
||||||
value = value * 100000000 + parse_eight_digits_unrolled(p);
|
value = value * 100000000 + parse_eight_digits_unrolled(p);
|
||||||
p += 8;
|
p += 8;
|
||||||
counter += 8;
|
counter += 8;
|
||||||
@ -233,8 +233,8 @@ parse_eight_digits(UC const *&p, limb &value, size_t &counter,
|
|||||||
|
|
||||||
template <typename UC>
|
template <typename UC>
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void
|
||||||
parse_one_digit(UC const *&p, limb &value, size_t &counter,
|
parse_one_digit(UC const *&p, limb &value, unsigned int &counter,
|
||||||
size_t &count) noexcept {
|
unsigned int &count) noexcept {
|
||||||
value = value * 10 + limb(*p - UC('0'));
|
value = value * 10 + limb(*p - UC('0'));
|
||||||
p++;
|
p++;
|
||||||
counter++;
|
counter++;
|
||||||
@ -248,7 +248,7 @@ add_native(bigint &big, limb power, limb value) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void
|
||||||
round_up_bigint(bigint &big, size_t &count) noexcept {
|
round_up_bigint(bigint &big, unsigned int &count) noexcept {
|
||||||
// need to round-up the digits, but need to avoid rounding
|
// need to round-up the digits, but need to avoid rounding
|
||||||
// ....9999 to ...10000, which could cause a false halfway point.
|
// ....9999 to ...10000, which could cause a false halfway point.
|
||||||
add_native(big, 10, 1);
|
add_native(big, 10, 1);
|
||||||
@ -259,17 +259,17 @@ round_up_bigint(bigint &big, size_t &count) noexcept {
|
|||||||
template <typename UC>
|
template <typename UC>
|
||||||
inline FASTFLOAT_CONSTEXPR20 void
|
inline FASTFLOAT_CONSTEXPR20 void
|
||||||
parse_mantissa(bigint &result, const parsed_number_string_t<UC> &num,
|
parse_mantissa(bigint &result, const parsed_number_string_t<UC> &num,
|
||||||
size_t max_digits, size_t &digits) noexcept {
|
unsigned int max_digits, unsigned int &digits) noexcept {
|
||||||
// try to minimize the number of big integer and scalar multiplication.
|
// try to minimize the number of big integer and scalar multiplication.
|
||||||
// therefore, try to parse 8 digits at a time, and multiply by the largest
|
// therefore, try to parse 8 digits at a time, and multiply by the largest
|
||||||
// scalar value (9 or 19 digits) for each step.
|
// scalar value (9 or 19 digits) for each step.
|
||||||
size_t counter = 0;
|
unsigned int counter = 0;
|
||||||
digits = 0;
|
digits = 0;
|
||||||
limb value = 0;
|
limb value = 0;
|
||||||
#ifdef FASTFLOAT_64BIT_LIMB
|
#ifdef FASTFLOAT_64BIT_LIMB
|
||||||
size_t step = 19;
|
unsigned int step = 19;
|
||||||
#else
|
#else
|
||||||
size_t step = 9;
|
unsigned int step = 9;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// process all integer digits.
|
// process all integer digits.
|
||||||
@ -444,8 +444,8 @@ inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa digit_comp(
|
|||||||
am.power2 -= invalid_am_bias;
|
am.power2 -= invalid_am_bias;
|
||||||
|
|
||||||
int32_t sci_exp = scientific_exponent(num);
|
int32_t sci_exp = scientific_exponent(num);
|
||||||
size_t max_digits = binary_format<T>::max_digits();
|
unsigned int max_digits = binary_format<T>::max_digits();
|
||||||
size_t digits = 0;
|
unsigned int digits = 0;
|
||||||
bigint bigmant;
|
bigint bigmant;
|
||||||
parse_mantissa(bigmant, num, max_digits, digits);
|
parse_mantissa(bigmant, num, max_digits, digits);
|
||||||
// can't underflow, since digits is at most max_digits.
|
// can't underflow, since digits is at most max_digits.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user