Commit e839d73
authored
perf: simply Specifier regex (#1106)
Examining the specifier regex, two potential optimizations seem
worthwhile:
1. Negative lookbehinds can be eliminated if we combine the operator
regex with the version regex -- this avoids crawling the same
characters of a string forwards and backwards.
2. Do more string operations, like `strip()` rather than having the
regex engine do this work.
These ideas are somewhat combined, in that getting rid of the lookbehinds
only really works by eliminating the group selectors in use. And removing
the group selectors in the regex requires that we do more string
operations.
This also interestingly results in a regex stored in the `Specifier`
which matches its secondary usage in `_tokenizer`, which was previously
very slightly misaligned (in that the group captures in the regex were
unused).1 parent e3af78f commit e839d73
2 files changed
+18
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 172 | + | |
| 173 | + | |
177 | 174 | | |
178 | 175 | | |
179 | 176 | | |
180 | 177 | | |
181 | 178 | | |
182 | 179 | | |
183 | | - | |
| 180 | + | |
184 | 181 | | |
185 | 182 | | |
186 | 183 | | |
| |||
192 | 189 | | |
193 | 190 | | |
194 | 191 | | |
195 | | - | |
| 192 | + | |
196 | 193 | | |
197 | 194 | | |
198 | 195 | | |
| |||
221 | 218 | | |
222 | 219 | | |
223 | 220 | | |
224 | | - | |
| 221 | + | |
225 | 222 | | |
226 | 223 | | |
227 | 224 | | |
| |||
244 | 241 | | |
245 | 242 | | |
246 | 243 | | |
247 | | - | |
248 | | - | |
249 | | - | |
| 244 | + | |
250 | 245 | | |
251 | 246 | | |
252 | 247 | | |
| |||
267 | 262 | | |
268 | 263 | | |
269 | 264 | | |
270 | | - | |
271 | | - | |
| 265 | + | |
272 | 266 | | |
273 | 267 | | |
274 | 268 | | |
| |||
295 | 289 | | |
296 | 290 | | |
297 | 291 | | |
298 | | - | |
299 | | - | |
| 292 | + | |
300 | 293 | | |
301 | 294 | | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
306 | 304 | | |
307 | 305 | | |
308 | 306 | | |
| |||
0 commit comments