diff --git a/ChangeLog b/ChangeLog index c2439e6833..a8110e4d67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Sep 20 04:42:18 2014 Masaki Matsushita + + * lib/csv.rb: avoid unnecessary object allocations. + patch is from Andrew Vit. [ruby-core:63215] [Feature #9952] + Sun Sep 21 12:10:18 2014 SHIBATA Hiroshi * lib/rexml/**/*.rb: removed commented-out code. diff --git a/lib/csv.rb b/lib/csv.rb index 60b22e76ba..c56f11bcf4 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -238,10 +238,10 @@ class CSV headers.each { |h| h.freeze if h.is_a? String } # handle extra headers or fields - @row = if headers.size > fields.size + @row = if headers.size >= fields.size headers.zip(fields) else - fields.zip(headers).map { |pair| pair.reverse } + fields.zip(headers).map { |pair| pair.reverse! } end end