Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify regexes #3055

Merged
merged 2 commits into from
Apr 1, 2019
Merged

Simplify regexes #3055

merged 2 commits into from
Apr 1, 2019

Conversation

kinow
Copy link
Member

@kinow kinow commented Apr 1, 2019

When using [...] in regexes, I believe we do not need to escape ., :, ), <, >, etc. As far as I know, we need to escape only the closing ], and the normal sequences like \n, \r, \t.

Python regex engine does the job of escaping these character anyway, but being regexes not always the fastest option, perhaps removing unnecessary escapes is a good idea?

Also included one more change (second commit) to use ([`\]) instead of (`|\). For two characters it makes no difference performance-wise. With more characters [`\] would probably be faster. But it's still easier to read I think?

Low priority, for Cylc 8 or later, without backport to Cylc 7 (I do not think it's necessary for the 7.8.x release series).

Cheers
Bruno

@kinow kinow self-assigned this Apr 1, 2019
@kinow kinow added the small label Apr 1, 2019
@kinow kinow added this to the later milestone Apr 1, 2019
@kinow
Copy link
Member Author

kinow commented Apr 1, 2019

Waited for Travis-CI to build the branch in my repository. If it fails here, it's one of those flaky tests, and Travis will need a kick.

@matthewrmshin
Copy link
Contributor

Yes. For completeness, the only other character that needs escaping in [...] is the hyphen/minus sign -, which is used in syntax like [a-z].

The only other thing we can do is to improve performance of regular expression logic is to pre-compile them where possible. (Not sure if this is still true or not.)

This change looks like good to go.

@matthewrmshin matthewrmshin modified the milestones: later, cylc-8.0a1 Apr 1, 2019
@matthewrmshin matthewrmshin requested a review from hjoliver April 1, 2019 08:38
Copy link
Member

@hjoliver hjoliver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two approvals (and @oliver-sanders seems to agree!)

@hjoliver hjoliver merged commit 5b0e240 into cylc:master Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants