about summary refs log tree commit homepage
path: root/lib/dtas
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-12-27 08:08:49 +0000
committerEric Wong <normalperson@yhbt.net>2013-12-27 08:08:49 +0000
commitdc89cfd111eff569bac3077b366c5ed8737d05a5 (patch)
tree8905b133e488eb14fd983e1c46a35b6ef2b98ed6 /lib/dtas
parent010e2862de13cdd1767e7b41f2e9045d6fc413ac (diff)
downloaddtas-dc89cfd111eff569bac3077b366c5ed8737d05a5.tar.gz
Favor &:method block calls to avoid captures.
Delay the check for inflight bytes while we're at it,
since we may never need the result of FIONREAD.
Diffstat (limited to 'lib/dtas')
-rw-r--r--lib/dtas/buffer/read_write.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/dtas/buffer/read_write.rb b/lib/dtas/buffer/read_write.rb
index 530a08d..08dfb01 100644
--- a/lib/dtas/buffer/read_write.rb
+++ b/lib/dtas/buffer/read_write.rb
@@ -41,8 +41,7 @@ module DTAS::Buffer::ReadWrite # :nodoc:
   end
 
   def broadcast_inf(targets)
-    bytes = inflight
-    nr_nb = targets.count { |sink| sink.nonblock? }
+    nr_nb = targets.count(&:nonblock?)
     if nr_nb == 0 || nr_nb == targets.size
       # if all targets are full, don't start until they're all writable
       r = IO.select(nil, targets, nil, 0) or return targets
@@ -59,6 +58,7 @@ module DTAS::Buffer::ReadWrite # :nodoc:
     again = {}
 
     # don't pin too much on one target
+    bytes = inflight
     bytes = bytes > MAX_AT_ONCE ? MAX_AT_ONCE : bytes
     buf = _rbuf
     @to_io.read(bytes, buf)