aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2023-02-08 08:08:04 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2023-02-08 08:08:04 +0300
commit99b0112a62351426df782b280810668d4ce1d651 (patch)
tree239e188c65a9bb4921c357d4215412679ec4d643
parent1e5926b916901f05acb5474e056989b592c011a3 (diff)
downloadydb-99b0112a62351426df782b280810668d4ce1d651.tar.gz
Update contrib/restricted/fast_float to 3.9.0
-rw-r--r--contrib/restricted/fast_float/README.md26
-rw-r--r--contrib/restricted/fast_float/include/fast_float/ascii_number.h4
-rw-r--r--contrib/restricted/fast_float/include/fast_float/digit_comparison.h4
-rw-r--r--contrib/restricted/fast_float/include/fast_float/fast_float.h2
-rw-r--r--contrib/restricted/fast_float/include/fast_float/fast_table.h6
-rw-r--r--contrib/restricted/fast_float/include/fast_float/float_common.h32
-rw-r--r--contrib/restricted/fast_float/include/fast_float/parse_number.h23
7 files changed, 75 insertions, 22 deletions
diff --git a/contrib/restricted/fast_float/README.md b/contrib/restricted/fast_float/README.md
index d6ae279527..7b3166abdd 100644
--- a/contrib/restricted/fast_float/README.md
+++ b/contrib/restricted/fast_float/README.md
@@ -124,6 +124,22 @@ You can parse delimited numbers:
// we have result == 324562.645.
```
+
+## Relation With Other 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)
+
+
+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).
+
## Reference
- Daniel Lemire, [Number Parsing at a Gigabyte per Second](https://arxiv.org/abs/2101.11408), Software: Practice and Experience 51 (8), 2021.
@@ -136,16 +152,6 @@ You can parse delimited numbers:
- [There is a C# port of the fast_float library](https://github.com/CarlVerret/csFastFloat) called `csFastFloat`.
-## Relation With Other Work
-
-The fast_float library is part of GCC (as of version 12): the `from_chars` function in GCC relies on fast_float.
-
-The fastfloat algorithm is part of the [LLVM standard libraries](https://github.com/llvm/llvm-project/commit/87c016078ad72c46505461e4ff8bfa04819fe7ba).
-
-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).
-
-There is a [derived implementation part of AdaCore](https://github.com/AdaCore/VSS).
-
## 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).
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 1783bd4ab1..ee376649c2 100644
--- a/contrib/restricted/fast_float/include/fast_float/ascii_number.h
+++ b/contrib/restricted/fast_float/include/fast_float/ascii_number.h
@@ -93,7 +93,11 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_
answer.valid = false;
answer.too_many_digits = false;
answer.negative = (*p == '-');
+#if FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default
+ if ((*p == '-') || (*p == '+')) {
+#else
if (*p == '-') { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
+#endif
++p;
if (p == pend) {
return answer;
diff --git a/contrib/restricted/fast_float/include/fast_float/digit_comparison.h b/contrib/restricted/fast_float/include/fast_float/digit_comparison.h
index 77c710f57f..4c43433966 100644
--- a/contrib/restricted/fast_float/include/fast_float/digit_comparison.h
+++ b/contrib/restricted/fast_float/include/fast_float/digit_comparison.h
@@ -125,8 +125,8 @@ void round_nearest_tie_even(adjusted_mantissa& am, int32_t shift, callback cb) n
halfway = uint64_t(1) << (shift - 1);
}
uint64_t truncated_bits = am.mantissa & mask;
- uint64_t is_above = truncated_bits > halfway;
- uint64_t is_halfway = truncated_bits == halfway;
+ bool is_above = truncated_bits > halfway;
+ bool is_halfway = truncated_bits == halfway;
// shift digits into position
if (shift == 64) {
diff --git a/contrib/restricted/fast_float/include/fast_float/fast_float.h b/contrib/restricted/fast_float/include/fast_float/fast_float.h
index ad3093ef88..d3497fd6b6 100644
--- a/contrib/restricted/fast_float/include/fast_float/fast_float.h
+++ b/contrib/restricted/fast_float/include/fast_float/fast_float.h
@@ -58,6 +58,6 @@ template<typename T>
from_chars_result from_chars_advanced(const char *first, const char *last,
T &value, parse_options options) noexcept;
-}
+} // namespace fast_float
#include "parse_number.h"
#endif // FASTFLOAT_FAST_FLOAT_H
diff --git a/contrib/restricted/fast_float/include/fast_float/fast_table.h b/contrib/restricted/fast_float/include/fast_float/fast_table.h
index 5766274ca4..aa7804b2e4 100644
--- a/contrib/restricted/fast_float/include/fast_float/fast_table.h
+++ b/contrib/restricted/fast_float/include/fast_float/fast_table.h
@@ -17,11 +17,11 @@ namespace fast_float {
*/
/**
- * The smallest non-zero float (binary64) is 2^−1074.
+ * The smallest non-zero float (binary64) is 2^-1074.
* We take as input numbers of the form w x 10^q where w < 2^64.
* We have that w * 10^-343 < 2^(64-344) 5^-343 < 2^-1076.
* However, we have that
- * (2^64-1) * 10^-342 = (2^64-1) * 2^-342 * 5^-342 > 2^−1074.
+ * (2^64-1) * 10^-342 = (2^64-1) * 2^-342 * 5^-342 > 2^-1074.
* Thus it is possible for a number of the form w * 10^-342 where
* w is a 64-bit value to be a non-zero floating-point number.
*********
@@ -694,6 +694,6 @@ const uint64_t powers_template<unused>::power_of_five_128[number_of_entries] = {
0x8e679c2f5e44ff8f,0x570f09eaa7ea7648,};
using powers = powers_template<>;
-}
+} // namespace fast_float
#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 c2084e0ed9..037cb0444c 100644
--- a/contrib/restricted/fast_float/include/fast_float/float_common.h
+++ b/contrib/restricted/fast_float/include/fast_float/float_common.h
@@ -14,7 +14,7 @@
|| (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)) )
#define FASTFLOAT_64BIT 1
#elif (defined(__i386) || defined(__i386__) || defined(_M_IX86) \
- || defined(__arm__) || defined(_M_ARM) \
+ || defined(__arm__) || defined(_M_ARM) || defined(__ppc__) \
|| defined(__MINGW32__) || defined(__EMSCRIPTEN__))
#define FASTFLOAT_32BIT 1
#else
@@ -50,7 +50,11 @@
#elif defined(sun) || defined(__sun)
#include <sys/byteorder.h>
#else
+#ifdef __has_include
+#if __has_include(<endian.h>)
#include <endian.h>
+#endif //__has_include(<endian.h>)
+#endif //__has_include
#endif
#
#ifndef __BYTE_ORDER__
@@ -77,12 +81,11 @@
#endif
#ifndef FASTFLOAT_ASSERT
-#define FASTFLOAT_ASSERT(x) { if (!(x)) abort(); }
+#define FASTFLOAT_ASSERT(x) { ((void)(x)); }
#endif
#ifndef FASTFLOAT_DEBUG_ASSERT
-#include <cassert>
-#define FASTFLOAT_DEBUG_ASSERT(x) assert(x)
+#define FASTFLOAT_DEBUG_ASSERT(x) { ((void)(x)); }
#endif
// rust style `try!()` macro, or `?` operator
@@ -218,8 +221,8 @@ constexpr static int32_t invalid_am_bias = -0x8000;
constexpr static double powers_of_ten_double[] = {
1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22};
-constexpr static float powers_of_ten_float[] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5,
- 1e6, 1e7, 1e8, 1e9, 1e10};
+constexpr static float powers_of_ten_float[] = {1e0f, 1e1f, 1e2f, 1e3f, 1e4f, 1e5f,
+ 1e6f, 1e7f, 1e8f, 1e9f, 1e10f};
// used for max_mantissa_double and max_mantissa_float
constexpr uint64_t constant_55555 = 5 * 5 * 5 * 5 * 5;
// Largest integer value v so that (5**index * v) <= 1<<53.
@@ -449,6 +452,23 @@ fastfloat_really_inline void to_float(bool negative, adjusted_mantissa am, T &va
#endif
}
+#if FASTFLOAT_SKIP_WHITE_SPACE // disabled by default
+inline bool is_space(uint8_t c) {
+ static const bool table[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ return table[c];
+ }
+#endif
} // namespace fast_float
#endif
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 477288199e..2493b02f2c 100644
--- a/contrib/restricted/fast_float/include/fast_float/parse_number.h
+++ b/contrib/restricted/fast_float/include/fast_float/parse_number.h
@@ -99,7 +99,25 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept {
//
// Note: This may fail to be accurate if fast-math has been
// enabled, as rounding conventions may not apply.
+ #if FASTFLOAT_VISUAL_STUDIO
+ # pragma warning(push)
+ // todo: is there a VS warning?
+ // see https://stackoverflow.com/questions/46079446/is-there-a-warning-for-floating-point-equality-checking-in-visual-studio-2013
+ #elif defined(__clang__)
+ # pragma clang diagnostic push
+ # pragma clang diagnostic ignored "-Wfloat-equal"
+ #elif defined(__GNUC__)
+ # pragma GCC diagnostic push
+ # pragma GCC diagnostic ignored "-Wfloat-equal"
+ #endif
return (fmini + 1.0f == 1.0f - fmini);
+ #if FASTFLOAT_VISUAL_STUDIO
+ # pragma warning(pop)
+ #elif defined(__clang__)
+ # pragma clang diagnostic pop
+ #elif defined(__GNUC__)
+ # pragma GCC diagnostic pop
+ #endif
}
} // namespace detail
@@ -118,6 +136,11 @@ from_chars_result from_chars_advanced(const char *first, const char *last,
from_chars_result answer;
+#if 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;