Patch #34161

Updated by Go MAEDA about 1 year ago

@String#tr@, @String#delete@, @String#tr@ and @String#squeeze@ @String#delete@ 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:

<pre>
bundle exec rubocop --only Performance/StringReplacement,Performance/Squeeze Performance/StringReplacement -a
</pre>

Back