summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-10 01:36:31 +0000
committerxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-10 01:36:31 +0000
commit32d1ee8798e37b73f972a652e2e019bcdd88379e (patch)
tree0a2aef6a03f8ffe88b79abe3c444fdcd1604641c /lib
parent17d0ab997181e34dd37f3096e7415488b986801f (diff)
downloadruby-32d1ee8798e37b73f972a652e2e019bcdd88379e.tar.gz
ruby-32d1ee8798e37b73f972a652e2e019bcdd88379e.tar.xz
ruby-32d1ee8798e37b73f972a652e2e019bcdd88379e.zip
* lib/cgi/cookie.rb (CGI::Cookie#to_s): performance improvement
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/cgi/cookie.rb31
1 files changed, 6 insertions, 25 deletions
diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb
index 6add74eab..befe1402e 100644
--- a/lib/cgi/cookie.rb
+++ b/lib/cgi/cookie.rb
@@ -96,31 +96,12 @@ class CGI
# 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