about summary refs log tree commit homepage
path: root/lib/unicorn/http_server.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-02-05 01:17:51 +0000
committerEric Wong <e@80x24.org>2015-02-05 17:18:11 +0000
commit28bb0e47541e49f36b96725732f7a7ae260bd5e9 (patch)
treed3997bef4d5912bff580b916c1dce2905d6b7821 /lib/unicorn/http_server.rb
parentfe83ead4eae6f011fa15f506cd80cb4256813a92 (diff)
downloadunicorn-28bb0e47541e49f36b96725732f7a7ae260bd5e9.tar.gz
In Ruby 1.9.2+, socket options may be specified using symbols
instead of constants to avoid the need to import Socket::Constants
into the namespace.  This also has a nice side-effect of reducing
the size of the bytecode by trading 3 instructions (getinlinecache,
getconstant, setinlinecache) for one "putobject" instruction.

Nowadays, we may also avoid defining OS-specific constants ourselves
since 1.9+ versions of Ruby already provide them to further reduce
bytecode size.

getsockopt also returns Socket::Option objects in 1.9.2+,
allowing us to avoid the larger "unpack('i')" method dispatch
for an operand-free "int" method call.

Finally, favor Object#nil? calls rather than "== nil" comparisons
to reduce bytecode size even more.

Since this code is only called at startup time, it does not benefit
from inline caching of constant lookups in current mainline Ruby.

Combined, these changes reduce YARV bytecode size by around 2K on a
64-bit system.
Diffstat (limited to 'lib/unicorn/http_server.rb')
0 files changed, 0 insertions, 0 deletions