ruby-changes:13983
From: ryan <ko1@a...>
Date: Mon, 16 Nov 2009 11:50:37 +0900 (JST)
Subject: [ruby-changes:13983] Ruby:r25791 (ruby_1_8): Minor cleanup to improve hash use
ryan 2009-11-16 11:50:14 +0900 (Mon, 16 Nov 2009) New Revision: 25791 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25791 Log: Minor cleanup to improve hash use Modified files: branches/ruby_1_8/lib/cgi.rb Index: ruby_1_8/lib/cgi.rb =================================================================== --- ruby_1_8/lib/cgi.rb (revision 25790) +++ ruby_1_8/lib/cgi.rb (revision 25791) @@ -971,7 +971,7 @@ end def read_multipart(boundary, content_length) - params = Hash.new([]) + params = Hash.new { |h,k| h[k] = [] } boundary = "--" + boundary quoted_boundary = Regexp.quote(boundary, "n") buf = "" @@ -1063,11 +1063,8 @@ /Content-Disposition:.* name="?([^\";\s]*)"?/ni.match(head) name = $1.dup - if params.has_key?(name) - params[name].push(body) - else - params[name] = [body] - end + params[name].push(body) + break if buf.size == 0 break if content_length == -1 end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/