diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-12-27 08:08:49 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-12-27 08:08:49 +0000 |
commit | dc89cfd111eff569bac3077b366c5ed8737d05a5 (patch) | |
tree | 8905b133e488eb14fd983e1c46a35b6ef2b98ed6 /lib/dtas/buffer/read_write.rb | |
parent | 010e2862de13cdd1767e7b41f2e9045d6fc413ac (diff) | |
download | dtas-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/buffer/read_write.rb')
-rw-r--r-- | lib/dtas/buffer/read_write.rb | 4 |
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) |