diff --git a/include/fast_float/ascii_number.h b/include/fast_float/ascii_number.h index dab21f2..fc5b4aa 100644 --- a/include/fast_float/ascii_number.h +++ b/include/fast_float/ascii_number.h @@ -50,8 +50,8 @@ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 uint64_t read8_to_u64(UC const *chars) { if (cpp20_and_in_constexpr() || !std::is_same::value) { uint64_t val = 0; - for (uint8_t i = 0; i != 8; ++i) { - val |= uint64_t(uint8_t(*chars)) << (i * 8); + for (uint_fast8_t i = 0; i != 8; ++i) { + val |= uint64_t(uint_fast8_t(*chars)) << (i * 8); ++chars; } return val; @@ -293,7 +293,7 @@ report_parse_error(UC const *p, parse_error error) noexcept { template fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t parse_number_string(UC const *p, UC const *pend, - parse_options_t const options) noexcept { + parse_options_t const &options) noexcept { // Cyclomatic complexity https://en.wikipedia.org/wiki/Cyclomatic_complexity // Consider refactoring the 'parse_number_string' function. // FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN fix this. @@ -507,7 +507,7 @@ parse_number_string(UC const *p, UC const *pend, template fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t parse_int_string(UC const *p, UC const *pend, T &value, - parse_options_t const options) noexcept { + parse_options_t const &options) noexcept { from_chars_result_t answer; @@ -549,7 +549,7 @@ parse_int_string(UC const *p, UC const *pend, T &value, loop_parse_if_eight_digits(p, pend, i); // use SIMD if possible } while (p != pend) { - uint8_t const digit = ch_to_digit(*p); + uint_fast8_t const digit = ch_to_digit(*p); if (digit >= options.base) { break; } @@ -574,7 +574,7 @@ parse_int_string(UC const *p, UC const *pend, T &value, answer.ptr = p; // check u64 overflow - uint8_t const max_digits = max_digits_u64(options.base); + uint_fast8_t const max_digits = max_digits_u64(options.base); if (digit_count > max_digits) { answer.ec = std::errc::result_out_of_range; return answer; diff --git a/include/fast_float/decimal_to_binary.h b/include/fast_float/decimal_to_binary.h index 847654d..d84e716 100644 --- a/include/fast_float/decimal_to_binary.h +++ b/include/fast_float/decimal_to_binary.h @@ -17,7 +17,7 @@ namespace fast_float { // most significant bits and the low part corresponding to the least significant // bits. // -template +template fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128 compute_product_approximation(int64_t q, uint64_t w) noexcept { int const index = 2 * int(q - powers::smallest_power_of_five); diff --git a/include/fast_float/digit_comparison.h b/include/fast_float/digit_comparison.h index f3f5e0c..9d92201 100644 --- a/include/fast_float/digit_comparison.h +++ b/include/fast_float/digit_comparison.h @@ -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(shift, 64)); + cb(am, std::min(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::mantissa_explicit_bits())) diff --git a/include/fast_float/fast_float.h b/include/fast_float/fast_float.h index 4c05c2d..4ca1a0a 100644 --- a/include/fast_float/fast_float.h +++ b/include/fast_float/fast_float.h @@ -43,7 +43,7 @@ from_chars(UC const *first, UC const *last, T &value, template FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars_advanced(UC const *first, UC const *last, T &value, - parse_options_t const options) noexcept; + parse_options_t const &options) noexcept; /** * from_chars for integer types. diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index a1c2fff..91b2205 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -89,7 +89,7 @@ template struct parse_options_t { /** The character used as decimal point */ UC const decimal_point; /** The base used for integers */ - uint8_t const base; /* only allowed from 2 to 36 */ + uint_fast8_t const base; /* only allowed from 2 to 36 */ FASTFLOAT_ASSUME(base >= 2 && base <= 36); }; @@ -460,11 +460,11 @@ struct adjusted_mantissa { am_pow_t power2; adjusted_mantissa() noexcept = default; - constexpr bool operator==(adjusted_mantissa const &o) const noexcept { + constexpr bool operator==(adjusted_mantissa const o) const noexcept { return mantissa == o.mantissa && power2 == o.power2; } - constexpr bool operator!=(adjusted_mantissa const &o) const noexcept { + constexpr bool operator!=(adjusted_mantissa const o) const noexcept { return mantissa != o.mantissa || power2 != o.power2; } }; @@ -1039,7 +1039,7 @@ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void to_float( #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN bool const negative, #endif - adjusted_mantissa const &am, T &value) noexcept { + adjusted_mantissa const am, T &value) noexcept { using equiv_uint = equiv_uint_t; equiv_uint word = equiv_uint(am.mantissa); word = equiv_uint(word | equiv_uint(am.power2) @@ -1195,18 +1195,18 @@ template constexpr uint64_t int_luts::min_safe_u64[]; #endif template -fastfloat_really_inline constexpr uint8_t ch_to_digit(UC c) noexcept { +fastfloat_really_inline constexpr uint_fast8_t ch_to_digit(UC c) noexcept { return int_luts<>::chdigit[static_cast(c)]; } -fastfloat_really_inline constexpr uint8_t -max_digits_u64(uint8_t base) noexcept { +fastfloat_really_inline constexpr uint_fast8_t +max_digits_u64(uint_fast8_t base) noexcept { return int_luts<>::maxdigits_u64[base - 2]; } // If a u64 is exactly max_digits_u64() in length, this is // the value below which it has definitely overflowed. -fastfloat_really_inline constexpr uint64_t min_safe_u64(uint8_t base) noexcept { +fastfloat_really_inline constexpr uint64_t min_safe_u64(uint_fast8_t base) noexcept { return int_luts<>::min_safe_u64[base - 2]; } diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 3d4e3d8..6e56b95 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -148,7 +148,7 @@ template struct from_chars_caller { template FASTFLOAT_CONSTEXPR20 static from_chars_result_t call(UC const *first, UC const *last, T &value, - parse_options_t const options) noexcept { + parse_options_t const &options) noexcept { return from_chars_advanced(first, last, value, options); } }; @@ -307,7 +307,7 @@ from_chars_advanced(parsed_number_string_t const &pns, T &value) noexcept { template FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars_float_advanced(UC const *first, UC const *last, T &value, - parse_options_t const options) noexcept { + parse_options_t const &options) noexcept { static_assert(is_supported_float_type::value, "only some floating-point types are supported"); @@ -371,7 +371,7 @@ from_chars(UC const *first, UC const *last, T &value, int const base) noexcept { template FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars_int_advanced(UC const *first, UC const *last, T &value, - parse_options_t const options) noexcept { + parse_options_t const &options) noexcept { static_assert(is_supported_integer_type::value, "only integer types are supported"); @@ -407,7 +407,7 @@ template <> struct from_chars_advanced_caller<1> { template FASTFLOAT_CONSTEXPR20 static from_chars_result_t call(UC const *first, UC const *last, T &value, - parse_options_t const options) noexcept { + parse_options_t const &options) noexcept { return from_chars_float_advanced(first, last, value, options); } }; @@ -416,7 +416,7 @@ template <> struct from_chars_advanced_caller<2> { template FASTFLOAT_CONSTEXPR20 static from_chars_result_t call(UC const *first, UC const *last, T &value, - parse_options_t const options) noexcept { + parse_options_t const &options) noexcept { return from_chars_int_advanced(first, last, value, options); } }; @@ -424,7 +424,7 @@ template <> struct from_chars_advanced_caller<2> { template FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars_advanced(UC const *first, UC const *last, T &value, - parse_options_t const options) noexcept { + parse_options_t const &options) noexcept { return from_chars_advanced_caller< size_t(is_supported_float_type::value) + 2 * size_t(is_supported_integer_type::value)>::call(first, last, value,