( )⚙ D8506 rust-regex: fix issues with regex anchoring and performance

This is an archive of the discontinued Mercurial Phabricator instance.

rust-regex: fix issues with regex anchoring and performance
ClosedPublic

Authored by Alphare on May 7 2020, 6:16 PM.

Details

Summary

It turns out that the way I tried to work around regex's behavior difference
with re2 and Python's re was 1) buggy and 2) much more complicated than
needed.

In a few words:
regex adds .* on either side of patterns when no start or end anchor is
present. My previous workaround put ^ or $ for every pattern, which is
wrong even without the other 2 bugs on top of it.
Using ^(?:<patterns>) right at the end of the regex path fixes the issue.
I've opened an issue to get a build option instead:
https://github.com/rust-lang/regex/issues/675

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.