Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork41
Commitb5517b2
committed
optimize positive lookahead at end of pattern
- we achieve this by moving a trailing positive lookahead outside our wrapped capture group 0.- if the contents of the lookahead are easy, and the rest of the expression is also easy, we can then delegate the whole regexp to regex-automata and fixup the capture groups afterwards.- If the contents are not easy, no harm is done because the expression retains the same semantics in our VM, as we only perform the move if the whole pattern is not self-recursive. Also, as it is done after parsing, any relative backreferences etc. should be unaffected.- Because it is done before analysis, no re-analysis needs to take place, so it is quite efficient.This allows us to take full advantage of regex-automata's prefilters etc, and in general delegating to the NFA should always be quicker than using a backtracking engine and trying each character position in the haystack one at a time.This type of regex pattern is a quite common scenario inside `.sublime-syntax` definitions which are compatible with Sublime Text's `sregex` engine.1 parent39bee77 commitb5517b2
File tree
14 files changed
+327
-34
lines changed- .github
- benches
- examples
- src
- tests
14 files changed
+327
-34
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 |
| - | |
| 1 | + |
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 |
| |
10 | 16 |
| |
11 | 17 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | 3 |
| |
4 |
| - | |
| 4 | + | |
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
|
Lines changed: 23 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| 15 | + | |
15 | 16 |
| |
| 17 | + | |
16 | 18 |
| |
17 | 19 |
| |
18 | 20 |
| |
| |||
47 | 49 |
| |
48 | 50 |
| |
49 | 51 |
| |
| 52 | + | |
50 | 53 |
| |
51 |
| - | |
| 54 | + | |
52 | 55 |
| |
53 | 56 |
| |
54 | 57 |
| |
55 | 58 |
| |
56 |
| - | |
57 |
| - | |
58 |
| - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
59 | 74 |
| |
60 | 75 |
| |
61 | 76 |
| |
| |||
70 | 85 |
| |
71 | 86 |
| |
72 | 87 |
| |
73 |
| - | |
74 |
| - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
75 | 92 |
| |
76 | 93 |
| |
77 | 94 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
134 | 134 |
| |
135 | 135 |
| |
136 | 136 |
| |
137 |
| - | |
| 137 | + | |
| 138 | + | |
138 | 139 |
| |
139 | 140 |
| |
140 | 141 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
86 | 86 |
| |
87 | 87 |
| |
88 | 88 |
| |
89 |
| - | |
| 89 | + | |
90 | 90 |
| |
91 | 91 |
| |
92 | 92 |
| |
|
Lines changed: 12 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
23 |
| - | |
| 23 | + | |
24 | 24 |
| |
25 | 25 |
| |
26 | 26 |
| |
| |||
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
38 | 42 |
| |
39 | 43 |
| |
40 | 44 |
| |
| |||
122 | 126 |
| |
123 | 127 |
| |
124 | 128 |
| |
125 |
| - | |
| 129 | + | |
| 130 | + | |
126 | 131 |
| |
127 | 132 |
| |
128 | 133 |
| |
| |||
132 | 137 |
| |
133 | 138 |
| |
134 | 139 |
| |
| 140 | + | |
| 141 | + | |
| 142 | + | |
135 | 143 |
| |
136 | 144 |
| |
137 |
| - | |
| 145 | + | |
| 146 | + | |
138 | 147 |
| |
139 | 148 |
| |
140 | 149 |
| |
|
Lines changed: 1 addition & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
251 | 251 |
| |
252 | 252 |
| |
253 | 253 |
| |
254 |
| - | |
255 |
| - | |
256 |
| - | |
| 254 | + | |
257 | 255 |
| |
258 | 256 |
| |
259 | 257 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
620 | 620 |
| |
621 | 621 |
| |
622 | 622 |
| |
| 623 | + | |
623 | 624 |
| |
624 | 625 |
| |
625 | 626 |
| |
|
0 commit comments
Comments
(0)