-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Detect regexes where a string could be used in .split #191
Comments
I think we have handled some code similar to this in the Performance cops. Specifically, I think |
@rrosenblum Thanks for the suggestion. |
I'm not seeing it:
|
@djberg96 what ruby release are you running. Here are my results on 2.7.4 from your benchmark snippet:
|
@tas50 That was 3.0.1. I just tried 2.7.2 and 2.6.6 as well. The 2.7.x results were similar to yours, whereas the 2.6.x results showed both much slower, but the regex was slightly faster. |
We've known for a while that the performance measurements for some of the cops can change across Ruby versions. I don't think we document the performance benefits based on Ruby version. Maybe one solution to this that we start documenting performance across Ruby versions, and we start to use that information for targeting whether a cop is enabled or not. benchmark-ips is the recommended tool for generating performance reports for snippets of code Many of the cops are based on snippets from fast-ruby. Unfortunately, this project doesn't appear to be well maintained anymore. At one point in time, they did have a build that would show off performance for different versions of Ruby |
Is your feature request related to a problem? Please describe.
I've noticed that sometimes regexes are used when a simple string would work fine. The code below could / should be simplified to be just a string
Describe the solution you'd like
Autocorrect to
This is more clear to anyone reading the code and it's 3x faster:
Describe alternatives you've considered
Not this time
The text was updated successfully, but these errors were encountered: