Commit 5bec54a
committed
syntax: optimize \B{10000}
Basically, whenever a counted repetition is applied to a sub-expression
that can only ever match the empty string, the counted repetition can be
reduced to 1. We can achieve that optimization very easily via the
Hir::repetition smart constructor.
This is somewhat important to do because otherwise one can write
something like \B{10000}. The higher level infrastructure is somewhat
dumb about this and will happily try to match \B over and over again. We
should probably improve the higher level aspects of this (because this
is not the only case that can cause the same assertions being repeatedly
evaluated at the same position), but this fixes the most obvious ones at
the HIR level.1 parent 64099ce commit 5bec54a
4 files changed
+22
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2854 | 2854 | | |
2855 | 2855 | | |
2856 | 2856 | | |
2857 | | - | |
| 2857 | + | |
2858 | 2858 | | |
2859 | | - | |
| 2859 | + | |
2860 | 2860 | | |
2861 | 2861 | | |
2862 | | - | |
2863 | | - | |
| 2862 | + | |
| 2863 | + | |
2864 | 2864 | | |
2865 | 2865 | | |
2866 | 2866 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
359 | 365 | | |
360 | 366 | | |
361 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
506 | | - | |
| 506 | + | |
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
| |||
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
543 | | - | |
| 543 | + | |
544 | 544 | | |
545 | 545 | | |
546 | 546 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3489 | 3489 | | |
3490 | 3490 | | |
3491 | 3491 | | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
| 3499 | + | |
| 3500 | + | |
3492 | 3501 | | |
3493 | 3502 | | |
3494 | 3503 | | |
| |||
0 commit comments