diff options
author | Eric Wong <e@80x24.org> | 2015-12-04 22:49:29 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-12-08 05:13:28 +0000 |
commit | b0cb2bb41e76c4c3bfedd87f49e5ff70e9b830e2 (patch) | |
tree | 9fe7e8181ea96596fea7e17914b4080d49810270 /lib/yahns/http_response.rb | |
parent | f6fc3ac41d8e43dfb8558be88ca4de9f6c856dd5 (diff) | |
download | yahns-opt-case.tar.gz |
Ruby-trunk (as of r52931) optimizes case dispatch for additional immediate values such as `nil', `true', and `false'. Rearrange our case statements (and take away some safety-checks :x) to take advantage of these optimizations in ruby-trunk. ref: https://bugs.ruby-lang.org/issues/11769 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/71818 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/71825
Diffstat (limited to 'lib/yahns/http_response.rb')
-rw-r--r-- | lib/yahns/http_response.rb | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb index 99bf664..cbfcf77 100644 --- a/lib/yahns/http_response.rb +++ b/lib/yahns/http_response.rb @@ -75,11 +75,11 @@ module Yahns::HttpResponse # :nodoc: case rv = wbuf.wbuf_close(self) when :ignore # hijacked @state = rv - when Yahns::StreamFile - @state = rv - :wait_writable when true, false http_response_done(rv) + else # Yahns::StreamFile + @state = rv + :wait_writable end else @state = wbuf @@ -162,9 +162,6 @@ module Yahns::HttpResponse # :nodoc: case rv = kgio_syssend(buf, flags) when nil # all done, likely break - when String - flags = MSG_DONTWAIT - buf = rv # hope the skb grows when :wait_writable, :wait_readable if k.output_buffering alive = hijack ? hijack : alive @@ -174,6 +171,9 @@ module Yahns::HttpResponse # :nodoc: else response_wait_write(rv) or return :close end + else # String + flags = MSG_DONTWAIT + buf = rv # hope the skb grows end while true end @@ -192,8 +192,6 @@ module Yahns::HttpResponse # :nodoc: case rv = kgio_trywrite(chunk) when nil # all done, likely and good! break - when String - chunk = rv # hope the skb grows when we loop into the trywrite when :wait_writable, :wait_readable if k.output_buffering wbuf = Yahns::Wbuf.new(body, alive, k.output_buffer_tmpdir, rv) @@ -202,6 +200,8 @@ module Yahns::HttpResponse # :nodoc: else response_wait_write(rv) or return :close end + else # String + chunk = rv # hope the skb grows when we loop into the trywrite end while true end end @@ -231,8 +231,6 @@ module Yahns::HttpResponse # :nodoc: case rv = kgio_trywrite(buf) when nil break - when String - buf = rv when :wait_writable, :wait_readable if self.class.output_buffering wbuf = buf.dup @@ -241,6 +239,8 @@ module Yahns::HttpResponse # :nodoc: else response_wait_write(rv) or return :close end + else # String + buf = rv end while true end end @@ -257,8 +257,6 @@ module Yahns::HttpResponse # :nodoc: : "HTTP/1.1 100 Continue\r\n\r\n".freeze case rv = kgio_trywrite(buf) - when String - buf = rv when :wait_writable, :wait_readable if self.class.output_buffering @state = Yahns::WbufStr.new(buf, :r100_done) @@ -266,8 +264,10 @@ module Yahns::HttpResponse # :nodoc: else response_wait_write(rv) or return :close end - else + when nil return rv + else # String + buf = rv end while true end end |