diff options
author | Eric Wong <e@80x24.org> | 2014-11-27 22:43:44 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2014-11-27 22:43:44 +0000 |
commit | ec8c095b9f6081ec1462db6c4392ab181bd6790e (patch) | |
tree | 19f7fa874624e35d165ee0937ada2b6140660e7e /lib/unicorn | |
parent | e0b53967d74362c28da16bc2ecfccfd00a00a523 (diff) | |
download | unicorn-ec8c095b9f6081ec1462db6c4392ab181bd6790e.tar.gz |
Replacing the Regexp argument to a rarely-called String#split with a literal String can save a little memory. The removed Regexp memsize is 469 bytes on Ruby 2.1: ObjectSpace.memsize_of(/,/) => 469 Is slightly smaller at 453 bytes on 2.2.0dev (r48474). These numbers do not include the 40-byte object overhead. Nevertheless, this is a waste for non-performance-critical code during the socket inheritance phase. A literal string has less overhead at 88 bytes: * 48 bytes for table entry in the frozen string table * 40 bytes for the object itself The downside of using a literal string for the String#split argument is a 40-byte string object gets allocated on every call, but this piece of code is only called once in a process lifetime.
Diffstat (limited to 'lib/unicorn')
-rw-r--r-- | lib/unicorn/http_server.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index 819a0a8..69bf362 100644 --- a/lib/unicorn/http_server.rb +++ b/lib/unicorn/http_server.rb @@ -770,7 +770,7 @@ class Unicorn::HttpServer def inherit_listeners! # inherit sockets from parents, they need to be plain Socket objects # before they become Kgio::UNIXServer or Kgio::TCPServer - inherited = ENV['UNICORN_FD'].to_s.split(/,/).map do |fd| + inherited = ENV['UNICORN_FD'].to_s.split(',').map do |fd| io = Socket.for_fd(fd.to_i) set_server_sockopt(io, listener_opts[sock_name(io)]) prevent_autoclose(io) |