[前][次][番号順一覧][スレッド一覧]

ruby-changes:35581

From: glass <ko1@a...>
Date: Sun, 21 Sep 2014 12:21:31 +0900 (JST)
Subject: [ruby-changes:35581] glass:r47663 (trunk): * lib/csv.rb: avoid unnecessary object allocations.

glass	2014-09-21 12:21:17 +0900 (Sun, 21 Sep 2014)

  New Revision: 47663

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47663

  Log:
    * lib/csv.rb: avoid unnecessary object allocations.
      patch is from Andrew Vit. [ruby-core:63215] [Feature #9952]

  Modified files:
    trunk/ChangeLog
    trunk/lib/csv.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47662)
+++ ChangeLog	(revision 47663)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Sep 20 04:42:18 2014  Masaki Matsushita <glass.saga@g...>
+
+	* 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@g...>
 
 	* lib/rexml/**/*.rb: removed commented-out code.
Index: lib/csv.rb
===================================================================
--- lib/csv.rb	(revision 47662)
+++ lib/csv.rb	(revision 47663)
@@ -238,10 +238,10 @@ class CSV https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L238
       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
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]