Actions
Patch #34161
closedReplace gsub with tr, delete, or squeeze
Description
String#tr
, String#delete
, and String#squeeze
are faster than String#gsub
.
https://docs.rubocop.org/rubocop-performance/cops_performance.html#performancestringreplacement
https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code
https://docs.rubocop.org/rubocop-performance/cops_performance.html#performancesqueeze
https://github.com/JuanitoFatas/fast-ruby#remove-extra-spaces-or-other-contiguous-characters-code
Replacement can be done with RuboCop:
bundle exec rubocop --only Performance/StringReplacement,Performance/Squeeze -a
Updated by Go MAEDA about 4 years ago
- Subject changed from Replace gsub with tr or delete to Replace gsub with tr, delete, or squeeze
- Description updated (diff)
Updated by Go MAEDA about 4 years ago
- Status changed from New to Closed
- Assignee set to Go MAEDA
Committed.
Actions