summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-21 03:21:17 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-21 03:21:17 +0000
commit5be5db63503251aa900386757e1a46a99b5052ec (patch)
treea28fda5f67fb4bbb50bb7d74e86695749c8d2cd3
parentbe1206c0ace306ebfbb3ab9ddd1cfec8fee230a9 (diff)
* lib/csv.rb: avoid unnecessary object allocations.
patch is from Andrew Vit. [ruby-core:63215] [Feature #9952] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/csv.rb4
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index c2439e6..a8110e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Sep 20 04:42:18 2014 Masaki Matsushita <glass.saga@gmail.com>
+
+ * 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 <shibata.hiroshi@gmail.com>
* lib/rexml/**/*.rb: removed commented-out code.
diff --git a/lib/csv.rb b/lib/csv.rb
index 60b22e7..c56f11b 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