Skip to content
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

DX-61115: [C++] Update fast_float version to 3.10.1 (#36434) #35

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions cpp/src/arrow/util/value_parsing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.

#define FASTFLOAT_ALLOWS_LEADING_PLUS 1

#include "arrow/util/value_parsing.h"

#include <string>
Expand Down
6 changes: 6 additions & 0 deletions cpp/src/arrow/util/value_parsing_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ TEST(StringConversion, ToFloat) {
AssertConversion<FloatType>("0", 0.0f);
AssertConversion<FloatType>("-0.0", -0.0f);
AssertConversion<FloatType>("-1e20", -1e20f);
AssertConversion<FloatType>("+Infinity", std::numeric_limits<float>::infinity());
AssertConversion<FloatType>("-Infinity", -std::numeric_limits<float>::infinity());
AssertConversion<FloatType>("Infinity", std::numeric_limits<float>::infinity());

AssertConversionFails<FloatType>("");
AssertConversionFails<FloatType>("e");
Expand All @@ -135,6 +138,9 @@ TEST(StringConversion, ToDouble) {
AssertConversion<DoubleType>("0", 0);
AssertConversion<DoubleType>("-0.0", -0.0);
AssertConversion<DoubleType>("-1e100", -1e100);
AssertConversion<DoubleType>("+Infinity", std::numeric_limits<double>::infinity());
AssertConversion<DoubleType>("-Infinity", -std::numeric_limits<double>::infinity());
AssertConversion<DoubleType>("Infinity", std::numeric_limits<double>::infinity());

AssertConversionFails<DoubleType>("");
AssertConversionFails<DoubleType>("e");
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/vendored/fast_float/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# fast_float

The files in this directory are vendored from fast_float
git tag `v3.8.1`.
git tag `v3.10.1`.

See https://github.com/fastfloat/fast_float

Expand All @@ -31,7 +31,7 @@ See https://github.com/fastfloat/fast_float
## How to update

You must replace `VERSION` in the command lines with suitable version
such as `3.8.1`.
such as `3.10.1`.

```bash
cpp/src/arrow/vendoered/fast_float/update.sh VERSION
Expand Down
15 changes: 11 additions & 4 deletions cpp/src/arrow/vendored/fast_float/ascii_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ namespace fast_float {

// Next function can be micro-optimized, but compilers are entirely
// able to optimize it well.
fastfloat_really_inline bool is_integer(char c) noexcept { return c >= '0' && c <= '9'; }
fastfloat_really_inline constexpr bool is_integer(char c) noexcept {
return c >= '0' && c <= '9';
}

fastfloat_really_inline uint64_t byteswap(uint64_t val) {
fastfloat_really_inline constexpr uint64_t byteswap(uint64_t val) {
return (val & 0xFF00000000000000) >> 56
| (val & 0x00FF000000000000) >> 40
| (val & 0x0000FF0000000000) >> 24
Expand Down Expand Up @@ -45,7 +47,8 @@ fastfloat_really_inline void write_u64(uint8_t *chars, uint64_t val) {
}

// credit @aqrit
fastfloat_really_inline uint32_t parse_eight_digits_unrolled(uint64_t val) {
fastfloat_really_inline FASTFLOAT_CONSTEXPR14
uint32_t parse_eight_digits_unrolled(uint64_t val) {
const uint64_t mask = 0x000000FF000000FF;
const uint64_t mul1 = 0x000F424000000064; // 100 + (1000000ULL << 32)
const uint64_t mul2 = 0x0000271000000001; // 1 + (10000ULL << 32)
Expand All @@ -60,7 +63,7 @@ fastfloat_really_inline uint32_t parse_eight_digits_unrolled(const char *chars)
}

// credit @aqrit
fastfloat_really_inline bool is_made_of_eight_digits_fast(uint64_t val) noexcept {
fastfloat_really_inline constexpr bool is_made_of_eight_digits_fast(uint64_t val) noexcept {
return !((((val + 0x4646464646464646) | (val - 0x3030303030303030)) &
0x8080808080808080));
}
Expand Down Expand Up @@ -94,7 +97,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;
Expand Down
Loading