diff options
author | Eric Wong <e@80x24.org> | 2015-04-07 08:09:09 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-04-07 08:09:09 +0000 |
commit | 9ae8745eb06cd601d5c1f56eb1e3c4b0678508f8 (patch) | |
tree | 33f720029efa674ad3b468f5a2a20a01f027f846 /lib/yahns/socket_helper.rb | |
parent | dad99b5ecd93cdf0a514ff9fb51d198f8aebb188 (diff) | |
download | yahns-9ae8745eb06cd601d5c1f56eb1e3c4b0678508f8.tar.gz |
Literal regexps costs over 400 bytes of memory on x86-64 per-site, so there's no point in using them to cause bloat at cold call sites where runtime performance does not matter.
Diffstat (limited to 'lib/yahns/socket_helper.rb')
-rw-r--r-- | lib/yahns/socket_helper.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/yahns/socket_helper.rb b/lib/yahns/socket_helper.rb index 66df8b0..a74f3f8 100644 --- a/lib/yahns/socket_helper.rb +++ b/lib/yahns/socket_helper.rb @@ -8,7 +8,7 @@ module Yahns::SocketHelper # :nodoc: def so_reuseport if defined?(Socket::SO_REUSEPORT) Socket::SO_REUSEPORT - elsif RUBY_PLATFORM =~ /linux/ + elsif RUBY_PLATFORM.include?('linux') 15 # only tested on x86_64 and i686 else nil @@ -108,7 +108,7 @@ module Yahns::SocketHelper # :nodoc: # returns rfc2732-style (e.g. "[::1]:666") addresses for IPv6 def tcp_name(sock) port, addr = Socket.unpack_sockaddr_in(sock.getsockname) - /:/ =~ addr ? "[#{addr}]:#{port}" : "#{addr}:#{port}" + addr.include?(':') ? "[#{addr}]:#{port}" : "#{addr}:#{port}" end # Returns the configuration name of a socket as a string. sock may |