Commit 3759186
committed
Avoid checking long strings for matching against whitespace
Previously, the string was checked for starting with newlines and ending
with spaces, then ensuring that the length of those substrings were
short enough to use our constant. Instead, only do the check for as many
items as we have in the WS constant.
In the worst case, this avoids an O(n) check if the input is a long
string of `\n`, possibly followed by a long string of spaces.1 parent 19ee1b8 commit 3759186
1 file changed
+18
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
2 | 8 | | |
3 | 9 | | |
4 | 10 | | |
| |||
358 | 364 | | |
359 | 365 | | |
360 | 366 | | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
365 | 378 | | |
366 | 379 | | |
367 | 380 | | |
| |||
0 commit comments