about summary refs log tree commit homepage
path: root/lib/yahns/wbuf.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-12-04 22:49:29 +0000
committerEric Wong <e@80x24.org>2015-12-08 05:13:28 +0000
commitb0cb2bb41e76c4c3bfedd87f49e5ff70e9b830e2 (patch)
tree9fe7e8181ea96596fea7e17914b4080d49810270 /lib/yahns/wbuf.rb
parentf6fc3ac41d8e43dfb8558be88ca4de9f6c856dd5 (diff)
downloadyahns-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/wbuf.rb')
-rw-r--r--lib/yahns/wbuf.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/yahns/wbuf.rb b/lib/yahns/wbuf.rb
index 1a24aab..f857a60 100644
--- a/lib/yahns/wbuf.rb
+++ b/lib/yahns/wbuf.rb
@@ -50,12 +50,12 @@ class Yahns::Wbuf # :nodoc:
     # try to bypass the VFS layer and write directly to the socket
     # if we're all caught up
     case rv = String === buf ? c.kgio_trywrite(buf) : c.kgio_trywritev(buf)
-    when String, Array
-      buf = rv # retry in loop
     when nil
       return # yay! hopefully we don't have to buffer again
     when :wait_writable, :wait_readable
       @busy = rv
+    else # String, Array
+      buf = rv # retry in loop
     end until @busy
 
     @tmpio ||= Yahns::TmpIO.new(@tmpdir)