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/sendfile_compat.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/sendfile_compat.rb')
-rw-r--r-- | lib/yahns/sendfile_compat.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/yahns/sendfile_compat.rb b/lib/yahns/sendfile_compat.rb index da2a9ec..6d4cc56 100644 --- a/lib/yahns/sendfile_compat.rb +++ b/lib/yahns/sendfile_compat.rb @@ -11,13 +11,13 @@ module Yahns::SendfileCompat str = io.read(count, buf) or return # nil for EOF n = 0 case rv = kgio_trywrite(str) - when String # partial write, keep trying - n += (str.size - rv.size) - str = rv when :wait_writable, :wait_readable return n > 0 ? n : rv when nil return n + str.size # yay! + else # String # partial write, keep trying + n += (str.size - rv.size) + str = rv end while true end end |