Commit b3fd7b2
parser.c: Use SWAR to skip consecutive spaces
Closes: #881
If we encounter a newline, it is likely that the document is pretty printed,
hence that the newline is followed by multiple spaces.
In such case we can use SWAR to count up to eight consecutive spaces at once.
```
== Parsing activitypub.json (58160 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
after 1.118k i/100ms
Calculating -------------------------------------
after 11.223k (± 0.7%) i/s (89.10 μs/i) - 57.018k in 5.080522s
Comparison:
before: 10834.4 i/s
after: 11223.4 i/s - 1.04x faster
== Parsing twitter.json (567916 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
after 118.000 i/100ms
Calculating -------------------------------------
after 1.188k (± 1.0%) i/s (841.62 μs/i) - 6.018k in 5.065355s
Comparison:
before: 1094.8 i/s
after: 1188.2 i/s - 1.09x faster
== Parsing citm_catalog.json (1727030 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
after 58.000 i/100ms
Calculating -------------------------------------
after 570.506 (± 3.7%) i/s (1.75 ms/i) - 2.900k in 5.091529s
Comparison:
before: 419.6 i/s
after: 570.5 i/s - 1.36x faster
== Parsing float parsing (2251051 bytes)
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
after 22.000 i/100ms
Calculating -------------------------------------
after 212.010 (± 1.9%) i/s (4.72 ms/i) - 1.078k in 5.086885s
Comparison:
before: 189.4 i/s
after: 212.0 i/s - 1.12x faster
```
Co-Authored-By: Scott Myron <[email protected]>1 parent 6f1d3c3 commit b3fd7b2
2 files changed
+33
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | 560 | | |
569 | 561 | | |
570 | 562 | | |
| |||
607 | 599 | | |
608 | 600 | | |
609 | 601 | | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
616 | 634 | | |
617 | 635 | | |
618 | 636 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
| |||
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
| 55 | + | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
| |||
0 commit comments