about summary refs log tree commit homepage
path: root/lib/yahns/worker.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/worker.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/worker.rb')
-rw-r--r--lib/yahns/worker.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/yahns/worker.rb b/lib/yahns/worker.rb
index d6e7364..aceaf4e 100644
--- a/lib/yahns/worker.rb
+++ b/lib/yahns/worker.rb
@@ -24,17 +24,17 @@ class Yahns::Worker # :nodoc:
   # dies unexpectedly.
   def yahns_step
     case buf = @to_io.kgio_tryread(4)
-    when String
-      # unpack the buffer and trigger the signal handler
-      signum = buf.unpack('l')
-      fake_sig(signum[0])
-      # keep looping, more signals may be queued
     when nil # EOF: master died, but we are at a safe place to exit
       fake_sig(:QUIT)
       @to_io.close
       return :ignore
     when :wait_readable # keep waiting
       return :ignore
+    else # String
+      # unpack the buffer and trigger the signal handler
+      signum = buf.unpack('l')
+      fake_sig(signum[0])
+      # keep looping, more signals may be queued
     end while true # loop, as multiple signals may be sent
   end