From dc89cfd111eff569bac3077b366c5ed8737d05a5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 27 Dec 2013 08:08:49 +0000 Subject: buffer/read_write: style and minor cleanup 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. --- lib/dtas/buffer/read_write.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/dtas/buffer') 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) -- cgit v1.2.3-24-ge0c7