diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2024-08-06 10:56:38 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2024-08-06 11:09:37 +0300 |
commit | 6da98cd7aef7a8a7d13bb1f4646ab9cb99c5c5f3 (patch) | |
tree | 84a87b2bc4aa47771bf4dbf90b79e976573d89fa /contrib/restricted | |
parent | e842851d5b299675ac1be291a152853c339a9add (diff) | |
download | ydb-6da98cd7aef7a8a7d13bb1f4646ab9cb99c5c5f3.tar.gz |
Update contrib/restricted/fast_float to 6.1.2
fe8a378bede398ff0144b74ffade134ea3355aa6
Diffstat (limited to 'contrib/restricted')
6 files changed, 55 insertions, 55 deletions
diff --git a/contrib/restricted/fast_float/README.md b/contrib/restricted/fast_float/README.md index d9208dad29..98da296fee 100644 --- a/contrib/restricted/fast_float/README.md +++ b/contrib/restricted/fast_float/README.md @@ -285,18 +285,19 @@ int main() { } `````` -## Relation With Other Work +## Users and Related Work The fast_float library is part of: - GCC (as of version 12): the `from_chars` function in GCC relies on fast_float. - [WebKit](https://github.com/WebKit/WebKit), the engine behind Safari (Apple's web browser) +- [DuckDB](https://duckdb.org) +- [Apache Arrow](https://github.com/apache/arrow/pull/8494) where it multiplied the number parsing speed by two or three times +- [Google Jsonnet](https://github.com/google/jsonnet) +- [ClickHouse](https://github.com/ClickHouse/ClickHouse) -The fastfloat algorithm is part of the [LLVM standard libraries](https://github.com/llvm/llvm-project/commit/87c016078ad72c46505461e4ff8bfa04819fe7ba). - -There is a [derived implementation part of AdaCore](https://github.com/AdaCore/VSS). - +The fastfloat algorithm is part of the [LLVM standard libraries](https://github.com/llvm/llvm-project/commit/87c016078ad72c46505461e4ff8bfa04819fe7ba). There is a [derived implementation part of AdaCore](https://github.com/AdaCore/VSS). The fast_float library provides a performance similar to that of the [fast_double_parser](https://github.com/lemire/fast_double_parser) library but using an updated algorithm reworked from the ground up, and while offering an API more in line with the expectations of C++ programmers. The fast_double_parser library is part of the [Microsoft LightGBM machine-learning framework](https://github.com/microsoft/LightGBM). @@ -313,9 +314,6 @@ The fast_float library provides a performance similar to that of the [fast_doubl - [There is a C# port of the fast_float library](https://github.com/CarlVerret/csFastFloat) called `csFastFloat`. -## Users - -The fast_float library is used by [Apache Arrow](https://github.com/apache/arrow/pull/8494) where it multiplied the number parsing speed by two or three times. It is also used by [ClickHouse](https://github.com/ClickHouse/ClickHouse) and by [Google Jsonnet](https://github.com/google/jsonnet). It is part of GCC (as of GCC 12). It is part of WebKit (Safari). ## How fast is it? @@ -381,7 +379,7 @@ the command line help. You may directly download automatically generated single-header files: -https://github.com/fastfloat/fast_float/releases/download/v6.1.1/fast_float.h +https://github.com/fastfloat/fast_float/releases/download/v6.1.2/fast_float.h ## RFC 7159 diff --git a/contrib/restricted/fast_float/include/fast_float/ascii_number.h b/contrib/restricted/fast_float/include/fast_float/ascii_number.h index 15a8a20f88..4c9da17a50 100644 --- a/contrib/restricted/fast_float/include/fast_float/ascii_number.h +++ b/contrib/restricted/fast_float/include/fast_float/ascii_number.h @@ -123,24 +123,6 @@ uint64_t simd_read8_to_u64(UC const*) { return 0; } - -fastfloat_really_inline FASTFLOAT_CONSTEXPR20 -void write_u64(uint8_t *chars, uint64_t val) { - if (cpp20_and_in_constexpr()) { - for(int i = 0; i < 8; ++i) { - *chars = uint8_t(val); - val >>= 8; - ++chars; - } - return; - } -#if FASTFLOAT_IS_BIG_ENDIAN == 1 - // Need to read as-if the number was in little-endian order. - val = byteswap(val); -#endif - ::memcpy(chars, &val, sizeof(uint64_t)); -} - // credit @aqrit fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint32_t parse_eight_digits_unrolled(uint64_t val) { @@ -367,7 +349,7 @@ parsed_number_string_t<UC> parse_number_string(UC const *p, UC const * pend, par ++p; } if ((p == pend) || !is_integer(*p)) { - if(!(fmt & chars_format::fixed)) { + if(!(fmt & chars_format::fixed) || (fmt & FASTFLOAT_JSONFMT)) { // We are in error. return answer; } diff --git a/contrib/restricted/fast_float/include/fast_float/decimal_to_binary.h b/contrib/restricted/fast_float/include/fast_float/decimal_to_binary.h index fec916f3a0..a4e245be86 100644 --- a/contrib/restricted/fast_float/include/fast_float/decimal_to_binary.h +++ b/contrib/restricted/fast_float/include/fast_float/decimal_to_binary.h @@ -127,8 +127,9 @@ adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept { // but in practice, we can win big with the compute_product_approximation if its additional branch // is easily predicted. Which is best is data specific. int upperbit = int(product.high >> 63); + int shift = upperbit + 64 - binary::mantissa_explicit_bits() - 3; - answer.mantissa = product.high >> (upperbit + 64 - binary::mantissa_explicit_bits() - 3); + answer.mantissa = product.high >> shift; answer.power2 = int32_t(detail::power(int32_t(q)) + upperbit - lz - binary::minimum_exponent()); if (answer.power2 <= 0) { // we have a subnormal? @@ -164,7 +165,7 @@ adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept { // To be in-between two floats we need that in doing // answer.mantissa = product.high >> (upperbit + 64 - binary::mantissa_explicit_bits() - 3); // ... we dropped out only zeroes. But if this happened, then we can go back!!! - if((answer.mantissa << (upperbit + 64 - binary::mantissa_explicit_bits() - 3)) == product.high) { + if((answer.mantissa << shift) == product.high) { answer.mantissa &= ~uint64_t(1); // flip it so that we do not round up } } diff --git a/contrib/restricted/fast_float/include/fast_float/float_common.h b/contrib/restricted/fast_float/include/fast_float/float_common.h index 8928da71c5..1c9835976c 100644 --- a/contrib/restricted/fast_float/include/fast_float/float_common.h +++ b/contrib/restricted/fast_float/include/fast_float/float_common.h @@ -564,7 +564,7 @@ inline constexpr int binary_format<double>::smallest_power_of_ten() { } template <> inline constexpr int binary_format<float>::smallest_power_of_ten() { - return -65; + return -64; } template <> inline constexpr size_t binary_format<double>::max_digits() { diff --git a/contrib/restricted/fast_float/include/fast_float/parse_number.h b/contrib/restricted/fast_float/include/fast_float/parse_number.h index a97906eb9e..57bcf46b74 100644 --- a/contrib/restricted/fast_float/include/fast_float/parse_number.h +++ b/contrib/restricted/fast_float/include/fast_float/parse_number.h @@ -187,35 +187,20 @@ from_chars_result_t<UC> from_chars(UC const * first, UC const * last, return from_chars_caller<T>::call(first, last, value, parse_options_t<UC>(fmt)); } +/** + * This function overload takes parsed_number_string_t structure that is created and populated + * either by from_chars_advanced function taking chars range and parsing options + * or other parsing custom function implemented by user. + */ template<typename T, typename UC> FASTFLOAT_CONSTEXPR20 -from_chars_result_t<UC> from_chars_advanced(UC const * first, UC const * last, - T &value, parse_options_t<UC> options) noexcept { +from_chars_result_t<UC> from_chars_advanced(parsed_number_string_t<UC>& pns, + T &value) noexcept { static_assert (is_supported_float_type<T>(), "only some floating-point types are supported"); static_assert (is_supported_char_type<UC>(), "only char, wchar_t, char16_t and char32_t are supported"); from_chars_result_t<UC> answer; -#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default - while ((first != last) && fast_float::is_space(uint8_t(*first))) { - first++; - } -#endif - if (first == last) { - answer.ec = std::errc::invalid_argument; - answer.ptr = first; - return answer; - } - parsed_number_string_t<UC> pns = parse_number_string<UC>(first, last, options); - if (!pns.valid) { - if (options.format & chars_format::no_infnan) { - answer.ec = std::errc::invalid_argument; - answer.ptr = first; - return answer; - } else { - return detail::parse_infnan(first, last, value); - } - } answer.ec = std::errc(); // be optimistic answer.ptr = pns.lastmatch; @@ -276,6 +261,40 @@ from_chars_result_t<UC> from_chars_advanced(UC const * first, UC const * last, return answer; } +template<typename T, typename UC> +FASTFLOAT_CONSTEXPR20 +from_chars_result_t<UC> from_chars_advanced(UC const * first, UC const * last, + T &value, parse_options_t<UC> options) noexcept { + + static_assert (is_supported_float_type<T>(), "only some floating-point types are supported"); + static_assert (is_supported_char_type<UC>(), "only char, wchar_t, char16_t and char32_t are supported"); + + from_chars_result_t<UC> answer; +#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default + while ((first != last) && fast_float::is_space(uint8_t(*first))) { + first++; + } +#endif + if (first == last) { + answer.ec = std::errc::invalid_argument; + answer.ptr = first; + return answer; + } + parsed_number_string_t<UC> pns = parse_number_string<UC>(first, last, options); + if (!pns.valid) { + if (options.format & chars_format::no_infnan) { + answer.ec = std::errc::invalid_argument; + answer.ptr = first; + return answer; + } else { + return detail::parse_infnan(first, last, value); + } + } + + // call overload that takes parsed_number_string_t directly. + return from_chars_advanced(pns, value); +} + template <typename T, typename UC, typename> FASTFLOAT_CONSTEXPR20 diff --git a/contrib/restricted/fast_float/ya.make b/contrib/restricted/fast_float/ya.make index f4c92eb84f..324d1643a9 100644 --- a/contrib/restricted/fast_float/ya.make +++ b/contrib/restricted/fast_float/ya.make @@ -10,9 +10,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(6.1.1) +VERSION(6.1.2) -ORIGINAL_SOURCE(https://github.com/fastfloat/fast_float/archive/v6.1.1.tar.gz) +ORIGINAL_SOURCE(https://github.com/fastfloat/fast_float/archive/v6.1.2.tar.gz) NO_COMPILER_WARNINGS() |