-
Notifications
You must be signed in to change notification settings - Fork 187
More fixed_regex_linter
features
#1166
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
Comments
Benchmarks:
Interestingly, |
we have a different linter for this actually. the linter looks for grepl and substr usages that can become startsWith/endsWith. because of the substr part it got a different linter |
Fine by me, although the static regex regex would need to be duplicated in that case. |
using the C version, we just reused is_not_regex after skipping the initial ^ |
Oh, yeah. We can do the same. |
This is mostly handled by What's left is to consider regexes like |
^ following the above comment, I'll close this & replace by a more focused issue extending |
Uh oh!
There was an error while loading. Please reload this page.
There are some more cases where regexes can be optimized away:
For regex detection functions, we can safely replace
grepl("^static_rx", x)
bystartsWith(x, "static_rx")
grepl("static_rx$", x)
byendsWith(x, "static_rx")
grepl("^static_rx$", x)
byx == "static_rx"
For substitution functions, we can replace
gsub("^static_rx$", "replacement", x)
by(function(.) { .[. == "static_rx"] <- "replacement"; . })(x)
The text was updated successfully, but these errors were encountered: