mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
* type usage fix for better performance in any hardware.
This commit is contained in:
parent
497e65b03f
commit
b8163709f5
@ -369,7 +369,7 @@ FASTFLOAT_CONSTEXPR20 bool large_mul(stackvec<size> &x, limb_span y) noexcept {
|
||||
}
|
||||
|
||||
template <typename = void> struct pow5_tables {
|
||||
static constexpr uint8_t large_step = 135;
|
||||
static constexpr uint_fast8_t large_step = 135;
|
||||
static constexpr uint64_t small_power_of_5[] = {
|
||||
1UL,
|
||||
5UL,
|
||||
@ -413,7 +413,7 @@ template <typename = void> struct pow5_tables {
|
||||
|
||||
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
|
||||
|
||||
template <typename T> constexpr uint8_t pow5_tables<T>::large_step;
|
||||
template <typename T> constexpr uint_fast8_t pow5_tables<T>::large_step;
|
||||
|
||||
template <typename T> constexpr uint64_t pow5_tables<T>::small_power_of_5[];
|
||||
|
||||
|
||||
@ -60,10 +60,10 @@ from_chars_advanced(UC const *first, UC const *last, T &value,
|
||||
*/
|
||||
FASTFLOAT_CONSTEXPR20 inline double
|
||||
integer_times_pow10(uint64_t const mantissa,
|
||||
int16_t const decimal_exponent) noexcept;
|
||||
int_fast16_t const decimal_exponent) noexcept;
|
||||
FASTFLOAT_CONSTEXPR20 inline double
|
||||
integer_times_pow10(int64_t const mantissa,
|
||||
int16_t const decimal_exponent) noexcept;
|
||||
int_fast16_t const decimal_exponent) noexcept;
|
||||
|
||||
/**
|
||||
* This function is a template overload of `integer_times_pow10()`
|
||||
@ -74,12 +74,12 @@ template <typename T>
|
||||
FASTFLOAT_CONSTEXPR20
|
||||
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
||||
integer_times_pow10(uint64_t const mantissa,
|
||||
int16_t const decimal_exponent) noexcept;
|
||||
int_fast16_t const decimal_exponent) noexcept;
|
||||
template <typename T>
|
||||
FASTFLOAT_CONSTEXPR20
|
||||
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
||||
integer_times_pow10(int64_t const mantissa,
|
||||
int16_t const decimal_exponent) noexcept;
|
||||
int_fast16_t const decimal_exponent) noexcept;
|
||||
|
||||
/**
|
||||
* from_chars for integer types.
|
||||
@ -88,7 +88,7 @@ template <typename T, typename UC = char,
|
||||
typename = FASTFLOAT_ENABLE_IF(is_supported_integer_type<T>::value)>
|
||||
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
||||
from_chars(UC const *first, UC const *last, T &value,
|
||||
int const base = 10) noexcept;
|
||||
uint_fast8_t const base = 10) noexcept;
|
||||
|
||||
} // namespace fast_float
|
||||
|
||||
|
||||
@ -287,8 +287,8 @@ struct is_supported_char_type
|
||||
template <typename UC>
|
||||
inline FASTFLOAT_CONSTEXPR14 bool
|
||||
fastfloat_strncasecmp(UC const *actual_mixedcase, UC const *expected_lowercase,
|
||||
uint8_t const length) noexcept {
|
||||
for (uint8_t i = 0; i++ != length;) {
|
||||
uint_fast8_t const length) noexcept {
|
||||
for (uint_fast8_t i = 0; i++ != length;) {
|
||||
UC const actual = actual_mixedcase[i];
|
||||
if ((actual < 256 ? actual | 32 : actual) != expected_lowercase[i]) {
|
||||
return false;
|
||||
@ -1059,7 +1059,7 @@ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void to_float(
|
||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||
|
||||
template <typename = void> struct space_lut {
|
||||
static constexpr uint8_t value[] = {
|
||||
static constexpr uint_fast8_t value[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@ -1075,12 +1075,12 @@ template <typename = void> struct space_lut {
|
||||
|
||||
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
|
||||
|
||||
template <typename T> constexpr uint8_t space_lut<T>::value[];
|
||||
template <typename T> constexpr uint_fast8_t space_lut<T>::value[];
|
||||
|
||||
#endif
|
||||
|
||||
template <typename UC> constexpr bool is_space(UC c) {
|
||||
return c < 256 && space_lut<>::value[uint8_t(c)];
|
||||
return c < 256 && space_lut<>::value[uint_fast8_t(c)];
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1166,7 +1166,7 @@ template <typename = void> struct int_luts {
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255};
|
||||
|
||||
static constexpr uint8_t maxdigits_u64[] = {
|
||||
static constexpr uint_fast8_t maxdigits_u64[] = {
|
||||
64, 41, 32, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 16, 16, 16, 16,
|
||||
15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13};
|
||||
|
||||
@ -1187,9 +1187,9 @@ template <typename = void> struct int_luts {
|
||||
|
||||
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
|
||||
|
||||
template <typename T> constexpr uint8_t int_luts<T>::chdigit[];
|
||||
template <typename T> constexpr uint_fast8_t int_luts<T>::chdigit[];
|
||||
|
||||
template <typename T> constexpr uint8_t int_luts<T>::maxdigits_u64[];
|
||||
template <typename T> constexpr uint_fast8_t int_luts<T>::maxdigits_u64[];
|
||||
|
||||
template <typename T> constexpr uint64_t int_luts<T>::min_safe_u64[];
|
||||
|
||||
|
||||
@ -374,15 +374,15 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
|
||||
|
||||
template <typename T, typename UC, typename>
|
||||
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
|
||||
from_chars(UC const *first, UC const *last, T &value, int const base) noexcept {
|
||||
from_chars(UC const *first, UC const *last, T &value,
|
||||
uint_fast8_t const base) noexcept {
|
||||
|
||||
static_assert(is_supported_integer_type<T>::value,
|
||||
"only integer types are supported");
|
||||
static_assert(is_supported_char_type<UC>::value,
|
||||
"only char, wchar_t, char16_t and char32_t are supported");
|
||||
|
||||
parse_options_t<UC> const options(chars_format::general, UC('.'),
|
||||
static_cast<uint_fast8_t>(base));
|
||||
parse_options_t<UC> const options(chars_format::general, UC('.'), base);
|
||||
return from_chars_advanced(first, last, value, options);
|
||||
}
|
||||
|
||||
@ -390,7 +390,7 @@ template <typename T>
|
||||
FASTFLOAT_CONSTEXPR20
|
||||
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
||||
integer_times_pow10(uint64_t const mantissa,
|
||||
int16_t const decimal_exponent) noexcept {
|
||||
int_fast16_t const decimal_exponent) noexcept {
|
||||
T value;
|
||||
if (clinger_fast_path_impl(mantissa, decimal_exponent,
|
||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||
@ -413,7 +413,7 @@ template <typename T>
|
||||
FASTFLOAT_CONSTEXPR20
|
||||
typename std::enable_if<is_supported_float_type<T>::value, T>::type
|
||||
integer_times_pow10(int64_t const mantissa,
|
||||
int16_t const decimal_exponent) noexcept {
|
||||
int_fast16_t const decimal_exponent) noexcept {
|
||||
#ifdef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||
FASTFLOAT_ASSUME(mantissa > 0);
|
||||
const am_mant_t m = static_cast<am_mant_t>(mantissa);
|
||||
@ -442,13 +442,13 @@ FASTFLOAT_CONSTEXPR20
|
||||
|
||||
FASTFLOAT_CONSTEXPR20 inline double
|
||||
integer_times_pow10(uint64_t const mantissa,
|
||||
int16_t const decimal_exponent) noexcept {
|
||||
int_fast16_t const decimal_exponent) noexcept {
|
||||
return integer_times_pow10<double>(mantissa, decimal_exponent);
|
||||
}
|
||||
|
||||
FASTFLOAT_CONSTEXPR20 inline double
|
||||
integer_times_pow10(int64_t const mantissa,
|
||||
int16_t const decimal_exponent) noexcept {
|
||||
int_fast16_t const decimal_exponent) noexcept {
|
||||
return integer_times_pow10<double>(mantissa, decimal_exponent);
|
||||
}
|
||||
|
||||
@ -460,7 +460,7 @@ FASTFLOAT_CONSTEXPR20
|
||||
std::is_integral<Int>::value &&
|
||||
!std::is_signed<Int>::value,
|
||||
T>::type
|
||||
integer_times_pow10(Int mantissa, int16_t decimal_exponent) noexcept {
|
||||
integer_times_pow10(Int mantissa, int_fast16_t decimal_exponent) noexcept {
|
||||
return integer_times_pow10<T>(static_cast<uint64_t>(mantissa),
|
||||
decimal_exponent);
|
||||
}
|
||||
@ -471,7 +471,7 @@ FASTFLOAT_CONSTEXPR20
|
||||
std::is_integral<Int>::value &&
|
||||
std::is_signed<Int>::value,
|
||||
T>::type
|
||||
integer_times_pow10(Int mantissa, int16_t decimal_exponent) noexcept {
|
||||
integer_times_pow10(Int mantissa, int_fast16_t decimal_exponent) noexcept {
|
||||
return integer_times_pow10<T>(static_cast<int64_t>(mantissa),
|
||||
decimal_exponent);
|
||||
}
|
||||
@ -479,14 +479,14 @@ FASTFLOAT_CONSTEXPR20
|
||||
template <typename Int>
|
||||
FASTFLOAT_CONSTEXPR20 typename std::enable_if<
|
||||
std::is_integral<Int>::value && !std::is_signed<Int>::value, double>::type
|
||||
integer_times_pow10(Int mantissa, int16_t decimal_exponent) noexcept {
|
||||
integer_times_pow10(Int mantissa, int_fast16_t decimal_exponent) noexcept {
|
||||
return integer_times_pow10(static_cast<uint64_t>(mantissa), decimal_exponent);
|
||||
}
|
||||
|
||||
template <typename Int>
|
||||
FASTFLOAT_CONSTEXPR20 typename std::enable_if<
|
||||
std::is_integral<Int>::value && std::is_signed<Int>::value, double>::type
|
||||
integer_times_pow10(Int mantissa, int16_t decimal_exponent) noexcept {
|
||||
integer_times_pow10(Int mantissa, int_fast16_t decimal_exponent) noexcept {
|
||||
return integer_times_pow10(static_cast<int64_t>(mantissa), decimal_exponent);
|
||||
}
|
||||
|
||||
|
||||
@ -2127,7 +2127,7 @@ TEST_CASE("bfloat16.general") {
|
||||
|
||||
template <typename Int, typename T, typename U>
|
||||
void verify_integer_times_pow10_result(Int const mantissa,
|
||||
int16_t const decimal_exponent,
|
||||
int_fast16_t const decimal_exponent,
|
||||
T const actual, U const expected) {
|
||||
static_assert(std::is_same<T, U>::value,
|
||||
"expected and actual types must match");
|
||||
@ -2146,7 +2146,7 @@ void verify_integer_times_pow10_result(Int const mantissa,
|
||||
|
||||
template <typename T, typename Int>
|
||||
T calculate_integer_times_pow10_expected_result(
|
||||
Int const mantissa, int16_t const decimal_exponent) {
|
||||
Int const mantissa, int_fast16_t const decimal_exponent) {
|
||||
std::string constructed_string =
|
||||
std::to_string(mantissa) + "e" + std::to_string(decimal_exponent);
|
||||
T expected_result;
|
||||
@ -2160,7 +2160,7 @@ T calculate_integer_times_pow10_expected_result(
|
||||
|
||||
template <typename Int>
|
||||
void verify_integer_times_pow10_dflt(Int const mantissa,
|
||||
int16_t const decimal_exponent,
|
||||
int_fast16_t const decimal_exponent,
|
||||
double const expected) {
|
||||
static_assert(std::is_integral<Int>::value);
|
||||
|
||||
@ -2174,7 +2174,7 @@ void verify_integer_times_pow10_dflt(Int const mantissa,
|
||||
|
||||
template <typename Int>
|
||||
void verify_integer_times_pow10_dflt(Int const mantissa,
|
||||
int16_t const decimal_exponent) {
|
||||
int_fast16_t const decimal_exponent) {
|
||||
static_assert(std::is_integral<Int>::value);
|
||||
|
||||
const auto expected_result =
|
||||
@ -2186,7 +2186,7 @@ void verify_integer_times_pow10_dflt(Int const mantissa,
|
||||
|
||||
template <typename T, typename Int>
|
||||
void verify_integer_times_pow10(Int const mantissa,
|
||||
int16_t const decimal_exponent,
|
||||
int_fast16_t const decimal_exponent,
|
||||
T const expected) {
|
||||
static_assert(std::is_floating_point<T>::value);
|
||||
static_assert(std::is_integral<Int>::value);
|
||||
@ -2201,7 +2201,7 @@ void verify_integer_times_pow10(Int const mantissa,
|
||||
|
||||
template <typename T, typename Int>
|
||||
void verify_integer_times_pow10(Int const mantissa,
|
||||
int16_t const decimal_exponent) {
|
||||
int_fast16_t const decimal_exponent) {
|
||||
static_assert(std::is_floating_point<T>::value);
|
||||
static_assert(std::is_integral<Int>::value);
|
||||
|
||||
@ -2214,7 +2214,7 @@ void verify_integer_times_pow10(Int const mantissa,
|
||||
namespace all_supported_types {
|
||||
template <typename Int>
|
||||
void verify_integer_times_pow10(Int const mantissa,
|
||||
int16_t const decimal_exponent) {
|
||||
int_fast16_t const decimal_exponent) {
|
||||
static_assert(std::is_integral<Int>::value);
|
||||
|
||||
// verify the "default" overload
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user