Repository navigation
Commit 121633d
authored
Hoist entity name regexp in Text.check (#391)
`Text.check` compiled the regexp `/\A#{Entity::NAME}\z/um` for each
named entity reference. Now the regexp is a constant. The regexp is the
same, so the output does not change.
| Input | Ruby 4.0 | 4.0 + YJIT | Ruby 2.6 | JRuby 10.1 |
|---|---:|---:|---:|---:|
| Text with predefined entities | -86% | -89% | -77% | -64% |
| Attribute values with entities | -74% | -82% | -58% | -47% |
Documents without named entity references do not use the changed line. I
measured no slowdown on them. I used 20 interleaved rounds and a
Mann-Whitney test (Apple M5).
Checks:
- `ruby test/run.rb` passes on Ruby 2.6, Ruby 4.0 and JRuby.
- Old and new outputs matched on 1,000,000 random documents.1 parent 5305ed3 commit 121633d
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
160 | | - | |
| 161 | + | |
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| |||
0 commit comments