From 9e7fb4e9b5d97cc75892c8faaea46444d438eb61 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 21 Nov 2015 08:52:28 +0000 Subject: tiny bytecode reductions for cold paths Less code in cold paths can improve speed for hot paths. Single-byte strings for String#split is optimized in mainline Ruby, so it's not actually a performance loss for sendfile_range in response.rb Regexps are at least 400 bytes each, so prefer non-Regexps if possible, especially for cold sites where performance does not matter. --- lib/rainbows/stream_response_epoll.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/rainbows/stream_response_epoll.rb') diff --git a/lib/rainbows/stream_response_epoll.rb b/lib/rainbows/stream_response_epoll.rb index 7c2f4f6..48ef298 100644 --- a/lib/rainbows/stream_response_epoll.rb +++ b/lib/rainbows/stream_response_epoll.rb @@ -39,7 +39,7 @@ module Rainbows::StreamResponseEpoll else if /\n/ =~ value # avoiding blank, key-only cookies with /\n+/ - buf << value.split(/\n+/).map! { |v| "#{key}: #{v}\r\n" }.join + value.split(/\n+/).each { |v| buf << "#{key}: #{v}\r\n" } else buf << "#{key}: #{value}\r\n" end -- cgit v1.2.3-24-ge0c7