rubocop / rubocop-performance

An extension of RuboCop focused on code performance checks.
https://docs.rubocop.org/rubocop-performance
MIT License
687 stars 81 forks source link

New `ZipForArrayWrapping` cop to detect and encourage the performant way to make an array of arrays #477

Open corsonknowles opened 3 weeks ago

corsonknowles commented 3 weeks ago

Is your feature request related to a problem? Please describe.

We would like to use the most efficient way to take an array and turn it into an array of arrays, 1 for each entry.

Describe the solution you'd like

We would like to use .zip as it is 40-90% more efficient than .map {|id| [id]}