ruby-changes:7760
From: xibbar <ko1@a...>
Date: Wed, 10 Sep 2008 10:36:47 +0900 (JST)
Subject: [ruby-changes:7760] Ruby:r19281 (trunk): * lib/cgi/cookie.rb (CGI::Cookie#to_s): performance improvement
xibbar 2008-09-10 10:36:31 +0900 (Wed, 10 Sep 2008) New Revision: 19281 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19281 Log: * lib/cgi/cookie.rb (CGI::Cookie#to_s): performance improvement Modified files: trunk/ChangeLog trunk/lib/cgi/cookie.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 19280) +++ ChangeLog (revision 19281) @@ -1,3 +1,8 @@ +Wed Sep 10 10:35:32 2008 Takeyuki Fujioka <xibbar@r...> + + * lib/cgi/cookie.rb (CGI::Cookie#to_s): performance improvement + from http://jp.rubyist.net/magazine/?0023-Cgirb. + Wed Sep 10 10:12:29 2008 akira yamada <akira@a...> * lib/sync.rb (Sync_m#sync_exclusive): fixed Index: lib/cgi/cookie.rb =================================================================== --- lib/cgi/cookie.rb (revision 19280) +++ lib/cgi/cookie.rb (revision 19281) @@ -96,31 +96,12 @@ # Convert the Cookie to its string representation. def to_s - buf = "" - buf += @name + '=' - - if @value.kind_of?(String) - buf += CGI::escape(@value) - else - buf += @value.collect{|v| CGI::escape(v) }.join("&") - end - - if @domain - buf += '; domain=' + @domain - end - - if @path - buf += '; path=' + @path - end - - if @expires - buf += '; expires=' + CGI::rfc1123_date(@expires) - end - - if @secure == true - buf += '; secure' - end - + val = @value.kind_of?(String) ? CGI::escape(@value) : @value.collect{|v| CGI::escape(v) }.join("&") + buf = "#{@name}=#{val}" + buf << "; domain=#{@domain}" if @domain + buf << "; path=#{@path}" if @path + buf << "; expires=#{CGI::rfc1123_date(@expires)}" if @expires + buf << "; secure" if @secure == true buf end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/