diff --git a/benchmarks/benchmark.cpp b/benchmarks/benchmark.cpp index 54d96d9..2510822 100644 --- a/benchmarks/benchmark.cpp +++ b/benchmarks/benchmark.cpp @@ -34,7 +34,7 @@ Value findmax_fastfloat(std::vector> &s, #ifdef USING_COUNTERS std::vector &aggregate #else - std::chrono::nanoseconds& time + std::chrono::nanoseconds &time #endif ) { Value answer = 0; @@ -55,7 +55,7 @@ Value findmax_fastfloat(std::vector> &s, t2 = std::chrono::high_resolution_clock::now(); time += t2 - t1; #endif - + if (ec != std::errc{}) { throw std::runtime_error("bug in findmax_fastfloat"); } @@ -71,7 +71,7 @@ time_it_ns(std::vector> &lines, T const &function, size_t repeat) { std::vector aggregate; bool printed_bug = false; - for (size_t i = 0; i < repeat; i++) { + for (size_t i = 0; i < repeat; i++) { double ts = function(lines, aggregate); if (ts == 0 && !printed_bug) { printf("bug\n"); @@ -155,7 +155,8 @@ time_it_ns(std::vector> &lines, T const &function, printf("bug\n"); printed_bug = true; } - double dif = std::chrono::duration_cast(time).count(); + double dif = + std::chrono::duration_cast(time).count(); average += dif; min_value = min_value < dif ? min_value : dif; } @@ -206,8 +207,9 @@ void process(std::vector &lines, size_t volume) { volume = 2 * volume; volumeMB = volume / (1024. * 1024.); std::cout << "UTF-16 volume = " << volumeMB << " MB " << std::endl; - pretty_print(volume, lines.size(), "fastfloat (64)", - time_it_ns(lines16, findmax_fastfloat, repeat)); + pretty_print( + volume, lines.size(), "fastfloat (64)", + time_it_ns(lines16, findmax_fastfloat, repeat)); pretty_print(volume, lines.size(), "fastfloat (32)", time_it_ns(lines16, findmax_fastfloat, repeat)); } @@ -229,29 +231,23 @@ void fileload(std::string filename) { #ifdef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN /* This code is a simple parser emulator */ for (size_t n = 0; n < line.size(); ++n) { - if ((line[n] >= '0' && line[n] <= '9')) - { + if ((line[n] >= '0' && line[n] <= '9')) { /* in the real parser we don't check anything else and call the from_chars function immediately */ const auto s = n; for (++n; n < line.size() && - ((line[n] >= '0' && line[n] <= '9') || - line[n] == 'e' || line[n] == 'E' || - line[n] == '.' || - line[n] == '-' || line[n] == '+' - /* last line for exponent sign*/ - ); - ++n) - { - + ((line[n] >= '0' && line[n] <= '9') || line[n] == 'e' || + line[n] == 'E' || line[n] == '.' || line[n] == '-' || + line[n] == '+' + /* last line for exponent sign*/ + ); + ++n) { } /*~ in the real parser we don't check anything else and call the from_chars function immediately */ volume += lines.emplace_back(line.substr(s, n)).size(); - } - else - { + } else { /* for the test we simplify skipped all other symbols, in real application this should be a full parser, that parse also any mathematical operations like + and - @@ -261,7 +257,7 @@ void fileload(std::string filename) { continue; } } - // in the real parser this part of code should return end token + // in the real parser this part of code should return end token #else volume += lines.emplace_back(line).size(); #endif diff --git a/include/fast_float/constexpr_feature_detect.h b/include/fast_float/constexpr_feature_detect.h index af6474b..0a98254 100644 --- a/include/fast_float/constexpr_feature_detect.h +++ b/include/fast_float/constexpr_feature_detect.h @@ -62,7 +62,11 @@ #if defined(__clang__) // needs testing #define FASTFLOAT_ASSUME(expr) __builtin_assume(expr) #elif defined(__GNUC__) && !defined(__ICC) // needs testing -#define FASTFLOAT_ASSUME(expr) if (expr) {} else { __builtin_unreachable(); } +#define FASTFLOAT_ASSUME(expr) \ + if (expr) { \ + } else { \ + __builtin_unreachable(); \ + } #elif defined(__ICC) // needs testing #define FASTFLOAT_ASSUME(expr) __assume(expr) #elif defined(_MSC_VER) diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index 3f1c8fc..1809483 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -67,8 +67,9 @@ template struct from_chars_result_t { using from_chars_result = from_chars_result_t; template struct parse_options_t { - FASTFLOAT_CONSTEXPR20 explicit parse_options_t(chars_format fmt = chars_format::general, - UC dot = UC('.'), const int b = 10) noexcept + FASTFLOAT_CONSTEXPR20 explicit parse_options_t( + chars_format fmt = chars_format::general, UC dot = UC('.'), + const int b = 10) noexcept : format(fmt), decimal_point(dot), base(static_cast(b)) {} /** Which number formats are accepted */ @@ -216,7 +217,8 @@ using parse_options = parse_options_t; namespace fast_float { -fastfloat_really_inline FASTFLOAT_CONSTEVAL20 bool cpp20_and_in_constexpr() noexcept { +fastfloat_really_inline FASTFLOAT_CONSTEVAL20 bool +cpp20_and_in_constexpr() noexcept { #if FASTFLOAT_HAS_IS_CONSTANT_EVALUATED return std::is_constant_evaluated(); #else @@ -304,7 +306,8 @@ struct value128 { uint64_t low; uint64_t high; - constexpr value128(uint64_t _low, uint64_t _high) noexcept : low(_low), high(_high) {} + constexpr value128(uint64_t _low, uint64_t _high) noexcept + : low(_low), high(_high) {} constexpr value128() noexcept : low(0), high(0) {} }; @@ -362,7 +365,8 @@ leading_zeroes(uint64_t input_num) noexcept { } // slow emulation routine for 32-bit -fastfloat_really_inline constexpr uint64_t emulu(uint32_t x, uint32_t y) noexcept { +fastfloat_really_inline constexpr uint64_t emulu(uint32_t x, + uint32_t y) noexcept { return x * (uint64_t)y; } @@ -995,12 +999,11 @@ binary_format::hidden_bit_mask() { } template -fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void -to_float( +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void to_float( #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN - bool const negative, + 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)