From: Nobuyoshi Nakada Date: 2017-08-28T22:20:00+09:00 Subject: [ruby-core:82486] Re: [ruby-cvs:66849] glass:r59671 (trunk): lib/csv.rb: refactor and optimize. This change 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: