-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Cop idea: prefer String#bytesize
over String#bytes#size
#475
Comments
This makes sense as a cop to me. The link you included in the PR (https://github.com/fastruby/fast-ruby#remove-extra-spaces-or-other-contiguous-characters-code) doesn't mention bytesize though, is there another source? |
I copy-pasted it from another config entry, that |
viralpraxis
added a commit
to viralpraxis/rubocop-performance
that referenced
this issue
Oct 22, 2024
The PR is ready for review |
viralpraxis
added a commit
to viralpraxis/rubocop-performance
that referenced
this issue
Oct 22, 2024
viralpraxis
added a commit
to viralpraxis/rubocop-performance
that referenced
this issue
Oct 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've seen some developers using
some_string.bytes.size
(orcount
/length
) instead of the constant-timeString#bytesize
method.In MRI there is no copy-on-write optimization for string/array conversion, so for large strings, the unnecessary array allocation could result in performance issues
I've opened #474 which will be finished if the idea accepted
The text was updated successfully, but these errors were encountered: