Skip to content

Commit d86c3f9

Browse files
committed
Make ryu a single header file and move it in vendor directory
1 parent 36e08c7 commit d86c3f9

File tree

8 files changed

+475
-489
lines changed

8 files changed

+475
-489
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Unreleased
44

5+
* Optimized floating point number parsing by integrating the ryu algorithm.
6+
57
### 2025-10-25 (2.15.2)
68

79
* Fix `JSON::Coder` to have one dedicated depth counter per invocation.

LEGAL

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ All the files in this distribution are covered under either the Ruby's
77
license (see the file COPYING) or public-domain except some files
88
mentioned below.
99

10-
ext/json/ext/parser/ryu_json.h::
11-
ext/json/ext/parser/ryu_table.h::
12-
These files are adapted from the Ryu algorithm by Ulf Adams.
13-
They are dual-licensed under Apache License 2.0 OR Boost Software License 1.0.
14-
See ext/json/ext/parser/LICENSE-Apache2 and ext/json/ext/parser/LICENSE-Boost
15-
for the full license texts.
10+
ext/json/ext/vendor/fpconv.h::
11+
This files is adapted from https://github.com/night-shift/fpconv
12+
It is licensed under Boost Software License 1.0.
13+
14+
ext/json/ext/vendor/jeaiii-ltoa.h::
15+
This files is adapted from https://github.com/jeaiii/itoa
16+
It is licensed under the MIT License
17+
18+
ext/json/ext/vendor/ryu.h::
19+
This file is adapted from the Ryu algorithm by Ulf Adams https://github.com/ulfjack/ryu.
20+
It is dual-licensed under Apache License 2.0 OR Boost Software License 1.0.

benchmark/parser.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,4 @@ def benchmark_parsing(name, json_output)
5757
benchmark_parsing "activitypub.json", File.read("#{__dir__}/data/activitypub.json")
5858
benchmark_parsing "twitter.json", File.read("#{__dir__}/data/twitter.json")
5959
benchmark_parsing "citm_catalog.json", File.read("#{__dir__}/data/citm_catalog.json")
60-
61-
# We now vendor Ryu (https://github.com/ulfjack/ryu), a state-of-the-art float parser
62-
# implemented in pure C. This gives us the same performance as rapidjson's C++ float parser,
63-
# achieving within-error-margin parity on float-heavy workloads like canada.json.
6460
benchmark_parsing "float parsing", File.read("#{__dir__}/data/canada.json")

ext/json/ext/parser/LICENSE-Apache2

Lines changed: 0 additions & 201 deletions
This file was deleted.

ext/json/ext/parser/LICENSE-Boost

Lines changed: 0 additions & 23 deletions
This file was deleted.

ext/json/ext/parser/parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "ruby/encoding.h"
33

44
// Minimal vendored Ryu float parser optimized for JSON parsing
5-
#include "ryu_json.h"
5+
#include "../vendor/ryu.h"
66

77
/* shims */
88
/* This is the fallback definition from Ruby 3.4 */

0 commit comments

Comments
 (0)