roo-rb / roo

Roo provides an interface to spreadsheets of several sorts.
MIT License
2.79k stars 501 forks source link

Refactor: Avoid Hash[] pattern #483

Closed chopraanmol1 closed 5 years ago

chopraanmol1 commented 5 years ago

Hash[] pattern creates many unnecessary intermediate arrays.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.003%) to 94.188% when pulling d0a5958502845cccb126a4a3503117fb8d986d00 on chopraanmol1:refactor_avoid_creating_hash_from_nested_array into 8091ff652b153cfee202b7026192541dca11ebb3 on roo-rb:master.

VitaliyAdamkov commented 5 years ago

@chopraanmol1 why don't you use :index_by instead?

(first_column..last_column).index_by { |col| cell(@header_line, col) }

sorry, i've forgot that it's method from rails