|
1 | 1 |
|
2 | | -## fast_float number parsing library: 4x faster than strtod |
| 2 | +## fast_float HE edition number parsing library. |
3 | 3 | [](https://github.com/irainman/fast_float/actions/workflows/ubuntu22.yml) |
4 | 4 | [](https://github.com/irainman/fast_float/actions/workflows/ubuntu22-clang.yml) |
5 | 5 | [](https://github.com/irainman/fast_float/actions/workflows/ubuntu24.yml) |
|
10 | 10 | [](https://github.com/irainman/fast_float/actions/workflows/vs17-clang-ci.yml) |
11 | 11 | [](https://www.codefactor.io/repository/github/irainman/fast_float) |
12 | 12 |
|
13 | | -*Note: This library is for C++ users. C programmers should consider [ffc.h](https://github.com/kolemannix/ffc.h). |
14 | | -## This is a fork of fast_float made by HedgehogInTheCPP with some additional options, code refactoring and big cleanup to maximize performance, reduce size and improve mainteinability, please give a star to this repo ^^ : |
| 13 | +## This is a fork of [fast_float](https://github.com/fastfloat/fast_float) made by HedgehogInTheCPP with some additional options, code refactoring and big cleanup to maximize performance, reduce size and improve mainteinability, please give a star to this repo ^^ |
15 | 14 |
|
| 15 | +### 🚀 Performance and Code Size Improvements |
| 16 | + |
| 17 | +* Optimized parsing logic for use as an **internal lightweight parser** (for example, inside other libraries). |
| 18 | +* Reduced binary size by conditionally excluding unneeded parsing features. |
| 19 | +* The `from_chars_result_t` structure is reduced to **4 bytes** for better memory efficiency. |
| 20 | +* Improved the `parsed_number_string_t` layout and increased `constexpr`/`consteval` propagation to enable compile-time optimizations. |
| 21 | +* Reduced register and cache pressure and branching in parsing hot paths. |
| 22 | +* Improved performance in both 64-bit and 32-bit builds for all supported types. |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +### ⚙️ New Configuration Macros |
| 27 | + |
| 28 | +Introduced new optional macros to minimize overhead when certain parsing features are not required: |
| 29 | + |
| 30 | +* **`FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN`** |
| 31 | + Restricts parsing to **positive C-style numbers only** — no sign characters, no `INF`, `INFINITY`, or `NaN` and no additional options like skip white spaces or support for Fortran or JSON. |
| 32 | + |
| 33 | +* **`FASTFLOAT_ONLY_ROUNDS_TO_NEAREST_SUPPORTED`** |
| 34 | + Assumes that only the **IEEE 754 “round-to-nearest”** rounding mode is needed, removing crutches support code for other modes. |
| 35 | + |
| 36 | +* **`FASTFLOAT_ISNOT_CHECKED_BOUNDS`** |
| 37 | + Disables bounds checking for input ranges that are assumed to be valid. |
| 38 | + Use only when inputs are guaranteed safe — this reduces branching and slightly improves performance. |
| 39 | + |
| 40 | +* **`FASTFLOAT_ASSUME`** |
| 41 | + Provides a portable abstraction for the compiler’s `[[assume]]` intrinsic. |
| 42 | + |
| 43 | +* **`FASTFLOAT_HAS_BYTESWAP`** |
| 44 | + Uses std::byteswap if available to reduce code size and speed up. |
| 45 | + |
| 46 | +* **`FASTFLOAT_HAS_BIT_CAST`** |
| 47 | + Uses std::bit_cast if available to reduce code size and speed up. |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +### 🧩 Remove Deprecated Macros |
| 52 | + |
| 53 | +* Removed obsolete macroses **`FASTFLOAT_ALLOWS_LEADING_PLUS`** and **`FASTFLOAT_SKIP_WHITE_SPACE`**, which are now superseded by the stricter limited-mode options above. |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +### 🧠 Internal Refactoring and Quality Improvements |
| 58 | + |
| 59 | +* Simplified internal parsing logic with compile-time branching controlled by the new macros. |
| 60 | +* Enhanced `constexpr` coverage across the codebase for greater compile-time evaluation. |
| 61 | +* Updated benchmarks and tests to validate new restricted configurations. |
| 62 | +* Fixed minor compiler warnings and addressed **PVS-Studio** static analysis feedback. |
| 63 | +* Properly use FASTFLOAT_SIMD_DISABLE_WARNINGS and FASTFLOAT_SIMD_RESTORE_WARNINGS only for instructions that allow unaligned loads. |
| 64 | +* Many small cleanups and fixes. |
| 65 | +* Added more comments about functionality and realization details. |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +### 📘 Documentation and Build |
| 70 | + |
| 71 | +* Updated **README.md** to describe all new configuration macros and their intended use cases. |
| 72 | +* Adjusted build scripts and benchmark configurations for the new compile-time flags. |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +✅ **Result:** |
| 77 | +Smaller, [faster by default](https://github.com/fastfloat/fast_float/pull/307#issuecomment-3775676197), and more configurable builds — now library can be used for **internal numeric parsers** or **embedded environments** — while maintaining full compatibility, functionality, and performance improvements in the default configuration. |
| 78 | + |
| 79 | + |
| 80 | +🔥 **Motivation:** |
16 | 81 | There is a really common use case in mathematical and other abstract syntax tree (AST)-like parsers that already processes |
17 | 82 | the sign and all other symbols before any number by itself. In this case you can use FastFloat to only parse positive numbers |
18 | 83 | in all supported formats with macros `FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN`, which significantly reduce the code size |
|
0 commit comments