mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
* Improving in code generation -> speedup.
* fix warning in 32 bit build.
This commit is contained in:
parent
97045b1d14
commit
56d423399d
@ -122,7 +122,7 @@ uint64_t simd_read8_to_u64(UC const *) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// credit @aqrit
|
// credit @aqrit
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint64_t
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint32_t
|
||||||
parse_eight_digits_unrolled(uint64_t val) noexcept {
|
parse_eight_digits_unrolled(uint64_t val) noexcept {
|
||||||
constexpr uint64_t mask = 0x000000FF000000FF;
|
constexpr uint64_t mask = 0x000000FF000000FF;
|
||||||
constexpr uint64_t mul1 = 0x000F424000000064; // 100 + (1000000ULL << 32)
|
constexpr uint64_t mul1 = 0x000F424000000064; // 100 + (1000000ULL << 32)
|
||||||
@ -130,12 +130,12 @@ parse_eight_digits_unrolled(uint64_t val) noexcept {
|
|||||||
val -= 0x3030303030303030;
|
val -= 0x3030303030303030;
|
||||||
val = (val * 10) + (val >> 8); // val = (val * 2561) >> 8;
|
val = (val * 10) + (val >> 8); // val = (val * 2561) >> 8;
|
||||||
val = (((val & mask) * mul1) + (((val >> 16) & mask) * mul2)) >> 32;
|
val = (((val & mask) * mul1) + (((val >> 16) & mask) * mul2)) >> 32;
|
||||||
return val;
|
return uint32_t(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call this if chars are definitely 8 digits.
|
// Call this if chars are definitely 8 digits.
|
||||||
template <typename UC>
|
template <typename UC>
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 uint64_t
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 uint32_t
|
||||||
parse_eight_digits_unrolled(UC const *chars) noexcept {
|
parse_eight_digits_unrolled(UC const *chars) noexcept {
|
||||||
if (cpp20_and_in_constexpr() || !has_simd_opt<UC>()) {
|
if (cpp20_and_in_constexpr() || !has_simd_opt<UC>()) {
|
||||||
return parse_eight_digits_unrolled(read8_to_u64(chars)); // truncation okay
|
return parse_eight_digits_unrolled(read8_to_u64(chars)); // truncation okay
|
||||||
|
|||||||
@ -604,11 +604,11 @@ struct bigint : pow5_tables<> {
|
|||||||
exp -= large_step;
|
exp -= large_step;
|
||||||
}
|
}
|
||||||
#ifdef FASTFLOAT_64BIT_LIMB
|
#ifdef FASTFLOAT_64BIT_LIMB
|
||||||
limb_t const small_step = 27;
|
limb_t constexpr small_step = 27;
|
||||||
limb const max_native = 7450580596923828125UL;
|
limb constexpr max_native = 7450580596923828125UL;
|
||||||
#else
|
#else
|
||||||
limb_t const small_step = 13;
|
limb_t constexpr small_step = 13;
|
||||||
limb const max_native = 1220703125U;
|
limb constexpr max_native = 1220703125U;
|
||||||
#endif
|
#endif
|
||||||
while (exp >= small_step) {
|
while (exp >= small_step) {
|
||||||
FASTFLOAT_TRY(small_mul(vec, max_native));
|
FASTFLOAT_TRY(small_mul(vec, max_native));
|
||||||
|
|||||||
@ -260,7 +260,7 @@ round_up_bigint(bigint &big, am_digits &count) noexcept {
|
|||||||
|
|
||||||
// parse the significant digits into a big integer
|
// parse the significant digits into a big integer
|
||||||
template <typename T, typename UC>
|
template <typename T, typename UC>
|
||||||
inline FASTFLOAT_CONSTEXPR20 am_digits
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 am_digits
|
||||||
parse_mantissa(bigint &result, const parsed_number_string_t<UC> &num) noexcept {
|
parse_mantissa(bigint &result, const parsed_number_string_t<UC> &num) 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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user