Commit 7b1a77d
committed
parser.c: Optimize
We can use `ctz` builtin to get the number of consecutive digits.
```
== Parsing float parsing (2251051 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
after 25.000 i/100ms
Calculating -------------------------------------
after 231.963 (± 0.0%) i/s (4.31 ms/i) - 1.175k in 5.065467s
Comparison:
before: 215.3 i/s
after: 232.0 i/s - 1.08x faster
```json_parse_digits
1 parent ded62a5 commit 7b1a77d
2 files changed
+13
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1094 | 1094 | | |
1095 | 1095 | | |
1096 | 1096 | | |
| 1097 | + | |
1097 | 1098 | | |
1098 | | - | |
| 1099 | + | |
1099 | 1100 | | |
1100 | 1101 | | |
1101 | 1102 | | |
1102 | 1103 | | |
1103 | 1104 | | |
1104 | | - | |
| 1105 | + | |
1105 | 1106 | | |
1106 | 1107 | | |
1107 | | - | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
1108 | 1115 | | |
1109 | 1116 | | |
1110 | | - | |
| 1117 | + | |
1111 | 1118 | | |
1112 | 1119 | | |
1113 | 1120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
0 commit comments