Commit 1ff72ce
committed
Optimize control char stripping
With the introduction of `Regexp.timeout`, which is set to 1s by
default in Rails 8.0, we ran into the control char stripping `gsub`
sometimes timing out.
This can be done much more efficiently with `String#tr_s`, it's about
3x faster and has guaranteed linear performance.1 parent f152a37 commit 1ff72ce
1 file changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
31 | | - | |
| 34 | + | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| |||
0 commit comments