Finally: after type refactoring is done give compiler opportunity to select best type for performance.

This commit is contained in:
IRainman 2025-05-05 18:21:35 +03:00
parent d67876e2f7
commit 8721491941
3 changed files with 10 additions and 10 deletions

View File

@ -32,7 +32,7 @@ typedef span<limb> limb_span;
// of bits required to store the largest bigint, which is
// `log2(10**(digits + max_exp))`, or `log2(10**(767 + 342))`, or
// ~3600 bits, so we round to 4000.
typedef uint16_t bigint_bits_t;
typedef uint_fast16_t bigint_bits_t;
constexpr bigint_bits_t bigint_bits = 4000;
constexpr limb_t bigint_limbs = bigint_bits / limb_bits;
@ -41,7 +41,7 @@ constexpr limb_t bigint_limbs = bigint_bits / limb_bits;
template <limb_t size> struct stackvec {
limb data[size];
// we never need more than 150 limbs
uint8_t length{0};
uint_fast8_t length{0};
FASTFLOAT_CONSTEXPR20 stackvec() noexcept = default;
stackvec(stackvec const &) = delete;

View File

@ -39,7 +39,7 @@ constexpr static uint64_t powers_of_ten_uint64[] = {1UL,
// effect on performance: in order to have a faster algorithm, we'd need
// to slow down performance for faster algorithms, and this is still fast.
template <typename UC>
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 int16_t
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 int_fast16_t
scientific_exponent(parsed_number_string_t<UC> const &num) noexcept {
am_mant_t mantissa = num.mantissa;
am_pow_t exponent = num.exponent;
@ -116,7 +116,7 @@ fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void round(adjusted_mantissa &am,
if (-am.power2 >= mantissa_shift) {
// have a denormal float
am_pow_t shift = -am.power2 + 1;
cb(am, std::min<int16_t>(shift, 64));
cb(am, std::min<int_fast16_t>(shift, 64));
// check for round-up: if rounding-nearest carried us to the hidden bit.
am.power2 = (am.mantissa <
(am_mant_t(1) << binary_format<T>::mantissa_explicit_bits()))

View File

@ -34,12 +34,12 @@
namespace fast_float {
// The number of digits in the mantissa.
typedef uint16_t am_digits;
typedef uint_fast16_t am_digits;
// The number of bits in the limb.
typedef uint8_t limb_t;
typedef uint_fast8_t limb_t;
typedef uint8_t chars_format_t;
typedef uint_fast8_t chars_format_t;
enum class chars_format : chars_format_t;
@ -444,13 +444,13 @@ full_multiplication(uint64_t a, uint64_t b) noexcept {
}
// Value of the mantissa.
typedef uint64_t am_mant_t;
typedef uint_fast64_t am_mant_t;
// Size of bits in the mantissa.
typedef uint8_t am_bits_t;
typedef uint_fast8_t am_bits_t;
// Power bias is signed for handling a denormal float
// or an invalid mantissa.
typedef int16_t am_pow_t;
typedef int_fast16_t am_pow_t;
// Bias so we can get the real exponent with an invalid adjusted_mantissa.
constexpr static am_pow_t invalid_am_bias = -0x8000;