Skip to content

Improwing speed and reduce code size when fast_float is using as internal parser code. #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 146 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
b0b1954
* Added a config macro FASTFLOAT_DISALLOW_ANY_LEADING_SYMBOLS_INCLUDE…
IRainman Mar 5, 2025
63f6abe
* Added an option disallow_leading_sign and stronger constexpr / cons…
IRainman Mar 5, 2025
e35e7c7
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Mar 6, 2025
2879564
more const
IRainman Mar 6, 2025
9ebac23
Added a config option FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN for…
IRainman Mar 6, 2025
7a38e1b
fix for 32 bit build. completely done. All other parser mode also wor…
IRainman Mar 6, 2025
bc3f331
# cleanup.
IRainman Mar 6, 2025
aba93f3
Additional compile time cleanup. When FASTFLOAT_ONLY_POSITIVE_C_NUMBE…
IRainman Mar 7, 2025
388426e
fix type conversion warning.
IRainman Mar 7, 2025
ae29a0d
PVS-Studio founds some errors, I fixed it.
IRainman Mar 7, 2025
f496321
Completely remove deprecated macroses FASTFLOAT_ALLOWS_LEADING_PLUS a…
IRainman Mar 8, 2025
ac22204
Update README.md
IRainman Mar 8, 2025
c2daa8a
Added FASTFLOAT_ASSUME for support attribute [[assume]] is declared i…
IRainman Mar 9, 2025
23a1367
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Mar 9, 2025
5097243
Fix compilation of benchmarks
IRainman Mar 9, 2025
a22dfc6
benchmark are updated, added AST parser emulation for FASTFLOAT_ONLY_…
IRainman Mar 9, 2025
354f4c3
Compilation fix.
IRainman Mar 9, 2025
63eb578
Add FASTFLOAT_HAS_BYTESWAP check.
IRainman Mar 9, 2025
6c499fd
FASTFLOAT_ASSUME review.
IRainman Mar 10, 2025
3e86e9a
####
IRainman Mar 10, 2025
7858023
Tests are updated:
IRainman Mar 10, 2025
474cc15
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Mar 10, 2025
681346f
Merge branch 'main' of https://github.com/fastfloat/fast_float into f…
IRainman Mar 12, 2025
cfd0963
Merge branch 'main' into main
IRainman Mar 12, 2025
3dd9a98
more const
IRainman Mar 12, 2025
1899647
GCC compilation fix.
IRainman Mar 12, 2025
e84f289
FASTFLOAT_IF_CONSTEXPR17
IRainman Mar 12, 2025
b869816
Merge branch 'main' of https://github.com/IRainman/fast_float into fa…
IRainman Mar 12, 2025
07ab87c
compilation fix in some cases.
IRainman Mar 12, 2025
3dd3712
lint
IRainman Mar 12, 2025
f3c6052
more constexpr.
IRainman Mar 12, 2025
27c0cd5
lint
IRainman Mar 12, 2025
2db26df
Remove consexpr/consteval from code that probably assumed to run in t…
IRainman Mar 12, 2025
1ab438c
Tests are updated.
IRainman Mar 12, 2025
929e981
lint
IRainman Mar 12, 2025
c08b7b1
tests updated
IRainman Mar 12, 2025
cd5db6f
lint
IRainman Mar 12, 2025
0188112
compilation fix in some old compilers.
IRainman Mar 12, 2025
ffd3590
benchmarks are improved: back to the cycle metering because when USIN…
IRainman Mar 24, 2025
c598a99
fix a warning.
IRainman Mar 24, 2025
9688b3b
improvements in benchmark.
IRainman Mar 24, 2025
1e3a135
reduce register pressure.
IRainman Mar 24, 2025
23395e4
try to compilation fix on Linux
IRainman Mar 24, 2025
a243773
try to compilation fix on Linux
IRainman Mar 24, 2025
d1617ab
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Mar 24, 2025
3eaa7d7
compilation fix.
IRainman Mar 24, 2025
0340e8b
build fix.
IRainman Mar 24, 2025
edb51b3
.
IRainman Mar 24, 2025
922eaa1
Merge branch 'fastfloat:main' into main
IRainman Mar 27, 2025
67aeda0
Update README.md
IRainman Mar 27, 2025
82477e9
Update README.md
IRainman Mar 27, 2025
01e9d35
Tests updated and fixed.
IRainman Mar 28, 2025
a2d81d4
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Mar 28, 2025
6687e73
Tests are updated.
IRainman Mar 28, 2025
34df2fc
Tests are updated.
IRainman Mar 28, 2025
8ebc89e
Reduce registers pressure.
IRainman Mar 28, 2025
fc9f61e
Cleanup initialization of the adjusted_mantissa.
IRainman Mar 28, 2025
ed87109
Remove FASTFLOAT_CONSTEVAL20 that I was added before and cleanup diff.
IRainman Mar 28, 2025
91e6c4d
.
IRainman Mar 28, 2025
afb54a5
Disable FASTFLOAT_ASSUME by default.
IRainman Mar 28, 2025
6aea2fb
initialization cleanup.
IRainman Mar 28, 2025
ee620a0
reduce registers pressure.
IRainman Mar 28, 2025
1651c2b
Readded FASTFLOAT_CONSTEVAL, but not used currently. Cleanup for FAST…
IRainman Apr 7, 2025
3faba01
Remove PVS.
IRainman Apr 7, 2025
4f0615b
Reduce register pressure and cleanup interface for standard.
IRainman Apr 7, 2025
8212e9e
fix warnings in the benchmark.
IRainman Apr 7, 2025
b261492
reduce register pressure.
IRainman Apr 7, 2025
a133b72
FASTFLOAT_ASSUME
IRainman Apr 8, 2025
b121f53
reduce register pressure.
IRainman Apr 8, 2025
5c61080
improvements of memory layout of parsed_number_string_t.
IRainman Apr 8, 2025
27f0265
style cleanup.
IRainman Apr 8, 2025
97bfec6
style fix.
IRainman Apr 8, 2025
b8f7771
after all sized checks is done I return the minimum registers size po…
IRainman Apr 8, 2025
f1b7f49
after all sized checks is done I return the minimum registers size po…
IRainman Apr 8, 2025
a591ca2
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Apr 8, 2025
7c96e3a
reduce size of from_chars_result_t to 4 bytes. Cleanup for usage FAST…
IRainman Apr 9, 2025
a081ebe
reduce size of from_chars_result_t to 4 bytes. Cleanup for usage FAST…
IRainman Apr 9, 2025
8d4ca69
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Apr 9, 2025
d32ae04
reduce size of from_chars_result_t to 4 bytes. Cleanup for usage FAST…
IRainman Apr 9, 2025
c762936
template interface cleanup for min_safe_u64 and max_digits_u64.
IRainman Apr 9, 2025
bbf4193
cleanup code generation for parse_mantissa.
IRainman Apr 9, 2025
2da25b5
trying to fix tests.
IRainman Apr 9, 2025
8e1fda5
fixes and cleanup for the parse_number_string function.
IRainman Apr 10, 2025
6cacae0
trying to fix tests.
IRainman Apr 10, 2025
68fe735
fix warnings.
IRainman Apr 10, 2025
f8625b6
fix warnings.
IRainman Apr 10, 2025
a4d1174
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Apr 10, 2025
e71bfff
additional improve for debug runtime.
IRainman Apr 11, 2025
88b3887
benchmark cleanup.
IRainman Apr 11, 2025
563648f
* fix errors in the parse_number_string.
IRainman Apr 11, 2025
0daee75
# format
IRainman Apr 11, 2025
1aed8ee
try reordering again.
IRainman Apr 11, 2025
f3db77a
try reordering again.
IRainman Apr 11, 2025
b0bae17
* added chars_format_t for performance reason.
IRainman Apr 11, 2025
69fbbff
try additional part...
IRainman Apr 11, 2025
ba1344c
* carefully work with types in the library.
IRainman Apr 12, 2025
0a18d6b
# format.
IRainman Apr 12, 2025
17ffdff
* additional types cleanup for speedup and reduce cache pressure.
IRainman Apr 12, 2025
c99930b
added additional macro FASTFLOAT_ONLY_ROUNDS_TO_NEAREST_SUPPORTED for…
IRainman Apr 29, 2025
7bd3c54
benchmarks are updated.
IRainman Apr 29, 2025
4e230e8
benchmarks are updated.
IRainman Apr 29, 2025
d67876e
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman Apr 29, 2025
58cb366
Finally: after type refactoring is done give compiler opportunity to …
IRainman May 5, 2025
8721491
Finally: after type refactoring is done give compiler opportunity to …
IRainman May 5, 2025
8ccb587
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman May 5, 2025
103f220
Final functions call optimization.
IRainman May 5, 2025
5356317
Fix compilation for older standards
IRainman May 5, 2025
0ba4e20
lint
IRainman May 5, 2025
1febc3a
Fix compilation for older standards
IRainman May 5, 2025
a8c5bd9
warning fix.
IRainman May 5, 2025
9049a1a
clang-format.
IRainman May 6, 2025
c94d3a0
clang-format
IRainman May 6, 2025
b2ea7bc
clang-format
IRainman May 6, 2025
afbb803
compilation fixes for std::bfloat16_t and std::float16_t. Sorry for t…
IRainman May 6, 2025
d5c05e5
additional type usage fixes and constexpr.
IRainman May 6, 2025
99d769d
clang-format
IRainman May 6, 2025
66363cc
try to fix stupid shit in the tests, meh.
IRainman May 6, 2025
ba3f7a6
.
IRainman May 6, 2025
f2befa5
.
IRainman May 6, 2025
e5f1897
compilation fixes.
IRainman May 6, 2025
30bd959
Update msys2-clang.yml
IRainman May 6, 2025
c339618
Update msys2.yml
IRainman May 6, 2025
3f9e488
format, fuck.
IRainman May 6, 2025
a10b25f
Merge branch 'main' of https://github.com/IRainman/fast_float
IRainman May 6, 2025
a4c573e
compilation fix
IRainman May 6, 2025
a3ccc1f
compilation fix
IRainman May 6, 2025
e446899
compilation fix.
IRainman May 6, 2025
6f789de
compilation fix.
IRainman May 6, 2025
1ec5f08
compilation fix
IRainman May 6, 2025
036ba0d
compilation fix
IRainman May 6, 2025
568dfef
compilation fix
IRainman May 6, 2025
2f8ff9a
compilation fix
IRainman May 6, 2025
4b94a61
type usage fix
IRainman May 6, 2025
23a9c3f
review of the parse_number_string function: now it's much faster, saf…
IRainman May 7, 2025
f7d5037
fix for the parse_number_string
IRainman May 7, 2025
6b22957
fix for the parse_number_string
IRainman May 7, 2025
3ee80c2
fix for the parse_number_string
IRainman May 7, 2025
88fff01
fix for the parse_number_string
IRainman May 7, 2025
f14d482
fix for the parse_number_string
IRainman May 7, 2025
7bac324
fix for the parse_number_string
IRainman May 7, 2025
a550415
additional fix for bfloat16_t. Sorry, I can't compile it's locally.
IRainman May 7, 2025
978441a
additional FASTFLOAT_HAS_BIT_CAST improve for older standards.
IRainman May 7, 2025
437a80c
fix for type usage in parse_int_string
IRainman May 8, 2025
5ae2fba
cleanup for parse_number_string
IRainman May 10, 2025
4213171
compilation fix for internal tests
IRainman May 12, 2025
a72afb5
unfck clang format
IRainman May 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 62 additions & 40 deletions include/fast_float/ascii_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ template <typename UC>
template <typename UC, FASTFLOAT_ENABLE_IF(!has_simd_opt<UC>()) = 0>
#endif
// dummy for compile
bool simd_parse_if_eight_digits_unrolled(UC const *, uint64_t &) {
FASTFLOAT_CONSTEVAL20 bool simd_parse_if_eight_digits_unrolled(UC const *, uint64_t &) {
return 0;
}

Expand Down Expand Up @@ -234,6 +234,7 @@ loop_parse_if_eight_digits(char const *&p, char const *const pend,

enum class parse_error {
no_error,
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
// [JSON-only] The minus sign must be followed by an integer.
missing_integer_after_sign,
// A sign must be followed by an integer or dot.
Expand All @@ -245,6 +246,7 @@ enum class parse_error {
// [JSON-only] If there is a decimal point, there must be digits in the
// fractional part.
no_digits_in_fractional_part,
#endif
// The mantissa must have at least one digit.
no_digits_in_mantissa,
// Scientific notation requires an exponential part.
Expand All @@ -255,7 +257,9 @@ template <typename UC> struct parsed_number_string_t {
int64_t exponent{0};
uint64_t mantissa{0};
UC const *lastmatch{nullptr};
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
bool negative{false};
#endif
bool valid{false};
bool too_many_digits{false};
// contains the range of the significant digits
Expand All @@ -269,7 +273,7 @@ using parsed_number_string = parsed_number_string_t<char>;

template <typename UC>
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t<UC>
report_parse_error(UC const *p, parse_error error) {
report_parse_error(UC const *p, parse_error error) noexcept {
parsed_number_string_t<UC> answer;
answer.valid = false;
answer.lastmatch = p;
Expand All @@ -282,38 +286,39 @@ report_parse_error(UC const *p, parse_error error) {
template <typename UC>
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t<UC>
parse_number_string(UC const *p, UC const *pend,
parse_options_t<UC> options) noexcept {
chars_format const fmt = detail::adjust_for_feature_macros(options.format);
UC const decimal_point = options.decimal_point;
const parse_options_t<UC> options) noexcept {

parsed_number_string_t<UC> answer;
answer.valid = false;
answer.too_many_digits = false;
// assume p < pend, so dereference without checks;
[[assume(p < pend)]]; // assume p < pend, so dereference without checks;
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
answer.negative = (*p == UC('-'));
// C++17 20.19.3.(7.1) explicitly forbids '+' sign here
if ((*p == UC('-')) ||
(uint64_t(fmt & chars_format::allow_leading_plus) &&
!uint64_t(fmt & detail::basic_json_fmt) && *p == UC('+'))) {
(uint64_t(options.format & chars_format::allow_leading_plus) &&
!uint64_t(options.format & detail::basic_json_fmt) && *p == UC('+'))) {
++p;
if (p == pend) {
return report_parse_error<UC>(
p, parse_error::missing_integer_or_dot_after_sign);
}
if (uint64_t(fmt & detail::basic_json_fmt)) {
if (uint64_t(options.format & detail::basic_json_fmt)) {
if (!is_integer(*p)) { // a sign must be followed by an integer
return report_parse_error<UC>(p,
parse_error::missing_integer_after_sign);
}
} else {
if (!is_integer(*p) &&
(*p !=
decimal_point)) { // a sign must be followed by an integer or the dot
options.decimal_point)) { // a sign must be followed by an integer or the dot
return report_parse_error<UC>(
p, parse_error::missing_integer_or_dot_after_sign);
}
}
}
#endif

UC const *const start_digits = p;

uint64_t i = 0; // an unsigned int avoids signed overflows (which are bad)
Expand All @@ -329,7 +334,8 @@ parse_number_string(UC const *p, UC const *pend,
UC const *const end_of_integer_part = p;
int64_t digit_count = int64_t(end_of_integer_part - start_digits);
answer.integer = span<UC const>(start_digits, size_t(digit_count));
if (uint64_t(fmt & detail::basic_json_fmt)) {
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
if (uint64_t(options.format & detail::basic_json_fmt)) {
// at least 1 digit in integer part, without leading zeros
if (digit_count == 0) {
return report_parse_error<UC>(p, parse_error::no_digits_in_integer_part);
Expand All @@ -339,9 +345,10 @@ parse_number_string(UC const *p, UC const *pend,
parse_error::leading_zeros_in_integer_part);
}
}
#endif

int64_t exponent = 0;
bool const has_decimal_point = (p != pend) && (*p == decimal_point);
bool const has_decimal_point = (p != pend) && (*p == options.decimal_point);
if (has_decimal_point) {
++p;
UC const *before = p;
Expand All @@ -358,22 +365,28 @@ parse_number_string(UC const *p, UC const *pend,
answer.fraction = span<UC const>(before, size_t(p - before));
digit_count -= exponent;
}
if (uint64_t(fmt & detail::basic_json_fmt)) {
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
if (uint64_t(options.format & detail::basic_json_fmt)) {
// at least 1 digit in fractional part
if (has_decimal_point && exponent == 0) {
return report_parse_error<UC>(p,
parse_error::no_digits_in_fractional_part);
}
} else if (digit_count ==
} else
#endif
if (digit_count ==
0) { // we must have encountered at least one integer!
return report_parse_error<UC>(p, parse_error::no_digits_in_mantissa);
}
int64_t exp_number = 0; // explicit exponential part
if ((uint64_t(fmt & chars_format::scientific) && (p != pend) &&
((UC('e') == *p) || (UC('E') == *p))) ||
(uint64_t(fmt & detail::basic_fortran_fmt) && (p != pend) &&
if ((uint64_t(options.format & chars_format::scientific) && (p != pend) &&
((UC('e') == *p) || (UC('E') == *p)))
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|| (uint64_t(options.format & detail::basic_fortran_fmt) && (p != pend) &&
((UC('+') == *p) || (UC('-') == *p) || (UC('d') == *p) ||
(UC('D') == *p)))) {
(UC('D') == *p)))
#endif
) {
UC const *location_of_e = p;
if ((UC('e') == *p) || (UC('E') == *p) || (UC('d') == *p) ||
(UC('D') == *p)) {
Expand All @@ -389,7 +402,7 @@ parse_number_string(UC const *p, UC const *pend,
++p;
}
if ((p == pend) || !is_integer(*p)) {
if (!uint64_t(fmt & chars_format::fixed)) {
if (!uint64_t(options.format & chars_format::fixed)) {
// The exponential part is invalid for scientific notation, so it must
// be a trailing token for fixed notation. However, fixed notation is
// disabled, so report a scientific notation error.
Expand All @@ -412,8 +425,8 @@ parse_number_string(UC const *p, UC const *pend,
}
} else {
// If it scientific and not fixed, we have to bail out.
if (uint64_t(fmt & chars_format::scientific) &&
!uint64_t(fmt & chars_format::fixed)) {
if (uint64_t(options.format & chars_format::scientific) &&
!uint64_t(options.format & chars_format::fixed)) {
return report_parse_error<UC>(p, parse_error::missing_exponential_part);
}
}
Expand All @@ -431,7 +444,8 @@ parse_number_string(UC const *p, UC const *pend,
// We need to be mindful of the case where we only have zeroes...
// E.g., 0.000000000...000.
UC const *start = start_digits;
while ((start != pend) && (*start == UC('0') || *start == decimal_point)) {
while ((start != pend) && (*start == UC('0') ||
*start == options.decimal_point)) {
if (*start == UC('0')) {
digit_count--;
}
Expand Down Expand Up @@ -474,30 +488,30 @@ template <typename T, typename UC>
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
parse_int_string(UC const *p, UC const *pend, T &value,
parse_options_t<UC> options) {
chars_format const fmt = detail::adjust_for_feature_macros(options.format);
int const base = options.base;

from_chars_result_t<UC> answer;

UC const *const first = p;

#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
bool const negative = (*p == UC('-'));
#ifdef FASTFLOAT_VISUAL_STUDIO
#pragma warning(push)
#pragma warning(disable : 4127)
#endif
if (!std::is_signed<T>::value && negative) {
if (!std::is_signed<T>::value && negative) {
#ifdef FASTFLOAT_VISUAL_STUDIO
#pragma warning(pop)
#endif
answer.ec = std::errc::invalid_argument;
answer.ptr = first;
return answer;
}
if ((*p == UC('-')) ||
(uint64_t(fmt & chars_format::allow_leading_plus) && (*p == UC('+')))) {
++p;
}
answer.ec = std::errc::invalid_argument;
answer.ptr = first;
return answer;
}
if ((*p == UC('-')) ||
(uint64_t(options.fmt & chars_format::allow_leading_plus) && (*p == UC('+')))) {
++p;
}
#endif

UC const *const start_num = p;

Expand All @@ -510,15 +524,15 @@ parse_int_string(UC const *p, UC const *pend, T &value,
UC const *const start_digits = p;

uint64_t i = 0;
if (base == 10) {
if (options.base == 10) {
loop_parse_if_eight_digits(p, pend, i); // use SIMD if possible
}
while (p != pend) {
uint8_t digit = ch_to_digit(*p);
if (digit >= base) {
const uint8_t digit = ch_to_digit(*p);
if (digit >= options.base) {
break;
}
i = uint64_t(base) * i + digit; // might overflow, check this later
i = static_cast<uint64_t>(options.base) * i + digit; // might overflow, check this later
p++;
}

Expand All @@ -539,26 +553,31 @@ parse_int_string(UC const *p, UC const *pend, T &value,
answer.ptr = p;

// check u64 overflow
size_t max_digits = max_digits_u64(base);
size_t const max_digits = max_digits_u64(options.base);
if (digit_count > max_digits) {
answer.ec = std::errc::result_out_of_range;
return answer;
}
// this check can be eliminated for all other types, but they will all require
// a max_digits(base) equivalent
if (digit_count == max_digits && i < min_safe_u64(base)) {
if (digit_count == max_digits && i < min_safe_u64(options.base)) {
answer.ec = std::errc::result_out_of_range;
return answer;
}

// check other types overflow
if (!std::is_same<T, uint64_t>::value) {
if (i > uint64_t(std::numeric_limits<T>::max()) + uint64_t(negative)) {
if (i > uint64_t(std::numeric_limits<T>::max())
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
+ uint64_t(negative)
#endif
) {
answer.ec = std::errc::result_out_of_range;
return answer;
}
}

#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
if (negative) {
#ifdef FASTFLOAT_VISUAL_STUDIO
#pragma warning(push)
Expand All @@ -576,8 +595,11 @@ parse_int_string(UC const *p, UC const *pend, T &value,
#pragma warning(pop)
#endif
} else {
#endif
value = T(i);
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
}
#endif

answer.ec = std::errc();
return answer;
Expand Down
20 changes: 10 additions & 10 deletions include/fast_float/bigint.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ template <uint16_t size> struct stackvec {
// we never need more than 150 limbs
uint16_t length{0};

stackvec() = default;
FASTFLOAT_CONSTEXPR20 stackvec() noexcept = default;
stackvec(stackvec const &) = delete;
stackvec &operator=(stackvec const &) = delete;
stackvec(stackvec &&) = delete;
stackvec &operator=(stackvec &&other) = delete;

// create stack vector from existing limb span.
FASTFLOAT_CONSTEXPR20 stackvec(limb_span s) {
FASTFLOAT_CONSTEXPR20 stackvec(limb_span s) noexcept {
FASTFLOAT_ASSERT(try_extend(s));
}

Expand Down Expand Up @@ -435,14 +435,14 @@ struct bigint : pow5_tables<> {
// storage of the limbs, in little-endian order.
stackvec<bigint_limbs> vec;

FASTFLOAT_CONSTEXPR20 bigint() : vec() {}
FASTFLOAT_CONSTEXPR20 bigint() noexcept : vec() {}

bigint(bigint const &) = delete;
bigint &operator=(bigint const &) = delete;
bigint(bigint &&) = delete;
bigint &operator=(bigint &&other) = delete;

FASTFLOAT_CONSTEXPR20 bigint(uint64_t value) : vec() {
FASTFLOAT_CONSTEXPR20 bigint(uint64_t value) noexcept : vec() {
#ifdef FASTFLOAT_64BIT_LIMB
vec.push_unchecked(value);
#else
Expand Down Expand Up @@ -517,8 +517,8 @@ struct bigint : pow5_tables<> {
FASTFLOAT_DEBUG_ASSERT(n != 0);
FASTFLOAT_DEBUG_ASSERT(n < sizeof(limb) * 8);

size_t shl = n;
size_t shr = limb_bits - shl;
size_t const shl = n;
size_t const shr = limb_bits - shl;
limb prev = 0;
for (size_t index = 0; index < vec.len(); index++) {
limb xi = vec[index];
Expand Down Expand Up @@ -556,8 +556,8 @@ struct bigint : pow5_tables<> {

// move the limbs left by `n` bits.
FASTFLOAT_CONSTEXPR20 bool shl(size_t n) noexcept {
size_t rem = n % limb_bits;
size_t div = n / limb_bits;
size_t const rem = n % limb_bits;
size_t const div = n / limb_bits;
if (rem != 0) {
FASTFLOAT_TRY(shl_bits(rem));
}
Expand Down Expand Up @@ -598,8 +598,8 @@ struct bigint : pow5_tables<> {
// multiply as if by 5 raised to a power.
FASTFLOAT_CONSTEXPR20 bool pow5(uint32_t exp) noexcept {
// multiply by a power of 5
size_t large_length = sizeof(large_power_of_5) / sizeof(limb);
limb_span large = limb_span(large_power_of_5, large_length);
size_t const large_length = sizeof(large_power_of_5) / sizeof(limb);
limb_span const large = limb_span(large_power_of_5, large_length);
while (exp >= large_step) {
FASTFLOAT_TRY(large_mul(vec, large));
exp -= large_step;
Expand Down
2 changes: 2 additions & 0 deletions include/fast_float/constexpr_feature_detect.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
defined(__cpp_lib_constexpr_algorithms) && \
__cpp_lib_constexpr_algorithms >= 201806L /*For std::copy and std::fill*/
#define FASTFLOAT_CONSTEXPR20 constexpr
#define FASTFLOAT_CONSTEVAL20 consteval
#define FASTFLOAT_IS_CONSTEXPR 1
#else
#define FASTFLOAT_CONSTEXPR20
#define FASTFLOAT_CONSTEVAL20
#define FASTFLOAT_IS_CONSTEXPR 0
#endif

Expand Down
2 changes: 1 addition & 1 deletion include/fast_float/decimal_to_binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace fast_float {
//
template <int bit_precision>
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128
compute_product_approximation(int64_t q, uint64_t w) {
compute_product_approximation(int64_t q, uint64_t w) noexcept {
int const index = 2 * int(q - powers::smallest_power_of_five);
// For small values of q, e.g., q in [0,27], the answer is always exact
// because The line value128 firstproduct = full_multiplication(w,
Expand Down
Loading