aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2024-02-12 12:58:51 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2024-02-12 13:12:43 +0300
commit027c1b3b95dfc9c4bee4587be95118ec896a6903 (patch)
tree924172f0436a288fc0957b9c9e14c0a76d909f42
parent762d2bbba8841b15a712e744c9c71763e6bae6d2 (diff)
downloadydb-027c1b3b95dfc9c4bee4587be95118ec896a6903.tar.gz
Update contrib/restricted/fast_float to 6.1.0
-rw-r--r--contrib/restricted/fast_float/README.md18
-rw-r--r--contrib/restricted/fast_float/include/fast_float/ascii_number.h11
-rw-r--r--contrib/restricted/fast_float/include/fast_float/float_common.h19
-rw-r--r--contrib/restricted/fast_float/include/fast_float/parse_number.h56
-rw-r--r--contrib/restricted/fast_float/ya.make4
5 files changed, 90 insertions, 18 deletions
diff --git a/contrib/restricted/fast_float/README.md b/contrib/restricted/fast_float/README.md
index 79ebedbd72..a7f72bedba 100644
--- a/contrib/restricted/fast_float/README.md
+++ b/contrib/restricted/fast_float/README.md
@@ -165,6 +165,16 @@ constexpr double constexptest() {
}
```
+## C++23: Fixed width floating-point types
+
+The library also supports fixed-width floating-point types such as `std::float32_t` and `std::float64_t`. E.g., you can write:
+
+```C++
+std::float32_t result;
+auto answer = fast_float::from_chars(f.data(), f.data() + f.size(), result);
+``````
+
+
## Non-ASCII Inputs
We also support UTF-16 and UTF-32 inputs, as well as ASCII/UTF-8, as in the following example:
@@ -305,7 +315,7 @@ The fast_float library provides a performance similar to that of the [fast_doubl
## 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 [Yandex ClickHouse](https://github.com/ClickHouse/ClickHouse) and by [Google Jsonnet](https://github.com/google/jsonnet).
+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?
@@ -371,7 +381,11 @@ the command line help.
You may directly download automatically generated single-header files:
-https://github.com/fastfloat/fast_float/releases/download/v6.0.0/fast_float.h
+https://github.com/fastfloat/fast_float/releases/download/v6.1.0/fast_float.h
+
+## RFC 7159
+
+If you need support for RFC 7159 (JSON standard), you may want to consider using the [fast_double_parser](https://github.com/lemire/fast_double_parser/) library instead.
## Credit
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 5d3eac9df5..15a8a20f88 100644
--- a/contrib/restricted/fast_float/include/fast_float/ascii_number.h
+++ b/contrib/restricted/fast_float/include/fast_float/ascii_number.h
@@ -442,8 +442,7 @@ parsed_number_string_t<UC> parse_number_string(UC const *p, UC const * pend, par
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, int base)
-{
+from_chars_result_t<UC> parse_int_string(UC const* p, UC const* pend, T& value, int base) {
from_chars_result_t<UC> answer;
UC const* const first = p;
@@ -463,9 +462,11 @@ from_chars_result_t<UC> parse_int_string(UC const* p, UC const* pend, T& value,
}
UC const* const start_num = p;
- while (*p == UC('0')) {
+
+ while (p!= pend && *p == UC('0')) {
++p;
}
+
const bool has_leading_zeros = p > start_num;
UC const* const start_digits = p;
@@ -528,8 +529,8 @@ from_chars_result_t<UC> parse_int_string(UC const* p, UC const* pend, T& value,
// this weird workaround is required because:
// - converting unsigned to signed when its value is greater than signed max is UB pre-C++23.
// - reinterpret_casting (~i + 1) would work, but it is not constexpr
- // this is always optimized into a neg instruction.
- value = T(-std::numeric_limits<T>::max() - T(i - std::numeric_limits<T>::max()));
+ // this is always optimized into a neg instruction (note: T is an integer type)
+ value = T(-std::numeric_limits<T>::max() - T(i - uint64_t(std::numeric_limits<T>::max())));
#ifdef FASTFLOAT_VISUAL_STUDIO
#pragma warning(pop)
#endif
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 b5a357b124..90b6ee888b 100644
--- a/contrib/restricted/fast_float/include/fast_float/float_common.h
+++ b/contrib/restricted/fast_float/include/fast_float/float_common.h
@@ -7,7 +7,11 @@
#include <cstring>
#include <type_traits>
#include <system_error>
-
+#ifdef __has_include
+ #if __has_include(<stdfloat>)
+ #error #include <stdfloat>
+ #endif
+#endif
#include "constexpr_feature_detect.h"
namespace fast_float {
@@ -188,7 +192,14 @@ fastfloat_really_inline constexpr bool cpp20_and_in_constexpr() {
template <typename T>
fastfloat_really_inline constexpr bool is_supported_float_type() {
- return std::is_same<T, float>::value || std::is_same<T, double>::value;
+ return std::is_same<T, float>::value || std::is_same<T, double>::value
+#if __STDCPP_FLOAT32_T__
+ || std::is_same<T, std::float32_t>::value
+#endif
+#if __STDCPP_FLOAT64_T__
+ || std::is_same<T, std::float64_t>::value
+#endif
+ ;
}
template <typename UC>
@@ -284,10 +295,10 @@ uint64_t umul128_generic(uint64_t ab, uint64_t cd, uint64_t *hi) {
uint64_t ad = emulu((uint32_t)(ab >> 32), (uint32_t)cd);
uint64_t bd = emulu((uint32_t)ab, (uint32_t)cd);
uint64_t adbc = ad + emulu((uint32_t)ab, (uint32_t)(cd >> 32));
- uint64_t adbc_carry = !!(adbc < ad);
+ uint64_t adbc_carry = (uint64_t)(adbc < ad);
uint64_t lo = bd + (adbc << 32);
*hi = emulu((uint32_t)(ab >> 32), (uint32_t)(cd >> 32)) + (adbc >> 32) +
- (adbc_carry << 32) + !!(lo < bd);
+ (adbc_carry << 32) + (uint64_t)(lo < bd);
return lo;
}
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 1fd587bb9a..a97906eb9e 100644
--- a/contrib/restricted/fast_float/include/fast_float/parse_number.h
+++ b/contrib/restricted/fast_float/include/fast_float/parse_number.h
@@ -10,7 +10,6 @@
#include <cstring>
#include <limits>
#include <system_error>
-
namespace fast_float {
@@ -133,11 +132,59 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept {
} // namespace detail
+template <typename T>
+struct from_chars_caller
+{
+ template <typename UC>
+ FASTFLOAT_CONSTEXPR20
+ static from_chars_result_t<UC> call(UC const * first, UC const * last,
+ T &value, parse_options_t<UC> options) noexcept {
+ return from_chars_advanced(first, last, value, options);
+ }
+};
+
+#if __STDCPP_FLOAT32_T__ == 1
+template <>
+struct from_chars_caller<std::float32_t>
+{
+ template <typename UC>
+ FASTFLOAT_CONSTEXPR20
+ static from_chars_result_t<UC> call(UC const * first, UC const * last,
+ std::float32_t &value, parse_options_t<UC> options) noexcept{
+ // if std::float32_t is defined, and we are in C++23 mode; macro set for float32;
+ // set value to float due to equivalence between float and float32_t
+ float val;
+ auto ret = from_chars_advanced(first, last, val, options);
+ value = val;
+ return ret;
+ }
+};
+#endif
+
+#if __STDCPP_FLOAT64_T__ == 1
+template <>
+struct from_chars_caller<std::float64_t>
+{
+ template <typename UC>
+ FASTFLOAT_CONSTEXPR20
+ static from_chars_result_t<UC> call(UC const * first, UC const * last,
+ std::float64_t &value, parse_options_t<UC> options) noexcept{
+ // if std::float64_t is defined, and we are in C++23 mode; macro set for float64;
+ // set value as double due to equivalence between double and float64_t
+ double val;
+ auto ret = from_chars_advanced(first, last, val, options);
+ value = val;
+ return ret;
+ }
+};
+#endif
+
+
template<typename T, typename UC, typename>
FASTFLOAT_CONSTEXPR20
from_chars_result_t<UC> from_chars(UC const * first, UC const * last,
T &value, chars_format fmt /*= chars_format::general*/) noexcept {
- return from_chars_advanced(first, last, value, parse_options_t<UC>{fmt});
+ return from_chars_caller<T>::call(first, last, value, parse_options_t<UC>(fmt));
}
template<typename T, typename UC>
@@ -145,7 +192,7 @@ 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 float and double are supported");
+ 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;
@@ -232,8 +279,7 @@ from_chars_result_t<UC> from_chars_advanced(UC const * first, UC const * last,
template <typename T, typename UC, typename>
FASTFLOAT_CONSTEXPR20
-from_chars_result_t<UC> from_chars(UC const* first, UC const* last, T& value, int base) noexcept
-{
+from_chars_result_t<UC> from_chars(UC const* first, UC const* last, T& value, int base) noexcept {
static_assert (is_supported_char_type<UC>(), "only char, wchar_t, char16_t and char32_t are supported");
from_chars_result_t<UC> answer;
diff --git a/contrib/restricted/fast_float/ya.make b/contrib/restricted/fast_float/ya.make
index acc85b8fc0..3910640cd3 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.0.0)
+VERSION(6.1.0)
-ORIGINAL_SOURCE(https://github.com/fastfloat/fast_float/archive/v6.0.0.tar.gz)
+ORIGINAL_SOURCE(https://github.com/fastfloat/fast_float/archive/v6.1.0.tar.gz)
NO_COMPILER_WARNINGS()