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

Warn when compiling regexes in a loop #598

Open
killercup opened this issue Jan 29, 2016 · 2 comments · May be fixed by #13412
Open

Warn when compiling regexes in a loop #598

killercup opened this issue Jan 29, 2016 · 2 comments · May be fixed by #13412
Assignees
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. L-perf Lint: Belongs in the perf lint group T-middle Type: Probably requires verifiying types

Comments

@killercup
Copy link
Member

killercup commented Jan 29, 2016

In #587, @BurntSushi says:

The biggest most important thing for regexes is to make sure you aren't compiling them every time you execute a search. I see it a lot in beginner code. Usually sticking them in lazy_static! is sufficient. But I suspect that might also be hard to detect.

@llogiq
Copy link
Contributor

llogiq commented Jan 29, 2016

An easy way would be detecting an ExprLoop containing a regex compile which does not use the iterated variable directly.

This could still have false positives, but should be good enough as a starting point.

@mcarton mcarton added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types A-lint Area: New lints L-perf Lint: Belongs in the perf lint group labels Jun 12, 2016
@GnomedDev
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. L-perf Lint: Belongs in the perf lint group T-middle Type: Probably requires verifiying types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants