From: Masaki Matsushita Date: 2017-08-29T10:55:08+09:00 Subject: [ruby-core:82496] Re: [ruby-cvs:66849] glass:r59671 (trunk): lib/csv.rb: refactor and optimize. This change > Is a keyword hash faster than a keyword argument? The change in those lines is to pass option[:encoding] to self.new. I might have to split this to another commit. 2017-08-28 22:20 GMT+09:00 Nobuyoshi Nakada : > On 2017/08/28 16:54, glass@ruby-lang.org wrote:> glass 2017-08-28 > 16:54:00 +0900 (Mon, 28 Aug 2017) >> >> New Revision: 59671 >> >> https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59671 >> >> Log: >> lib/csv.rb: refactor and optimize. This change >> includes the patch from marshall-lee. >> close #1168 > Is a keyword hash faster than a keyword argument? > > @@ -1188,11 +1189,11 @@ > # The :row_sep +option+ defaults to $INPUT_RECORD_SEPARATOR > # ($/) when calling this method. > # > - def self.generate_line(row, encoding: nil, **options) > + def self.generate_line(row, **options) > options = {row_sep: $INPUT_RECORD_SEPARATOR}.merge(options) > str = String.new > - if encoding > - str.force_encoding(encoding) > + if options[:encoding] > + str.force_encoding(options[:encoding]) > elsif field = row.find { |f| not f.nil? } > str.force_encoding(String(field).encoding) > end > > Unsubscribe: > Unsubscribe: