1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib/webrick
normal 3b92c63158 webrick/httpresponse: minor cleanups to reduce memory use
I never knew "format" was a global method alias for "sprintf";
so it was confusing to me.  Normally, one would use "sprintf"
since it's also available in many other languages, but
Integer#to_s avoids parsing a format string so it's less
bug-prone.

Furthermore, favor string interpolation over String#<< since it
is easier for the VM to optimize memory allocation (as in r60320).
Interpolation also reduces method calls and memory overhead
for inline method cache.

Finally, ensure we clear all short-lived buffers for body
responses.  A similar change was made and measured for Net::*
in r58840 showing a large memory reduction on some workloads.

* webrick/httpresponse.rb (send_body_io): favor String#to_s,
  reduce method calls for String#<<,
  clear `buf' when done,
  avoid extra String#bytesize calls

* (send_body_string): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-31 01:37:37 +00:00
..
httpauth
httpservlet Remove unnecessary require 'thread' 2017-10-08 07:00:01 +00:00
accesslog.rb
cgi.rb
compat.rb
config.rb
cookie.rb
htmlutils.rb
httpauth.rb
httpproxy.rb webrick: handle EAGAIN/EWOULDBLOCK on proxy connections 2017-09-19 08:39:22 +00:00
httprequest.rb
httpresponse.rb webrick/httpresponse: minor cleanups to reduce memory use 2017-10-31 01:37:37 +00:00
https.rb
httpserver.rb
httpservlet.rb
httpstatus.rb
httputils.rb Define the MIME type for JSON in WEBrick::HTTPUtils::DefaultMimeTypes. 2017-09-19 01:54:28 +00:00
httpversion.rb
log.rb
server.rb webrick: fix up r60172 and r60210 2017-10-18 23:34:02 +00:00
ssl.rb
utils.rb Remove unnecessary require 'thread' 2017-10-08 07:00:01 +00:00
version.rb
webrick.gemspec Fixed invalid gemspec. 2017-10-05 01:43:47 +00:00