From 62d9c8ea87dbd34eeaad211586015d879636eb0b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 4 Dec 2011 22:39:07 +0000 Subject: socket_common: small simplification in read() calculation Minor cleanup, one less un-optimized method dispatch. --- lib/mogilefs/socket_common.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mogilefs/socket_common.rb b/lib/mogilefs/socket_common.rb index 298e3da..404acd0 100644 --- a/lib/mogilefs/socket_common.rb +++ b/lib/mogilefs/socket_common.rb @@ -43,9 +43,9 @@ module MogileFS::SocketCommon def read(size, buf = "", timeout = 5) timed_read(size, buf, timeout) or return # nil/EOF - while size > buf.bytesize + while (size -= buf.bytesize) > 0 tmp ||= "" - timed_read(size - buf.bytesize, tmp, timeout) or return buf # truncated + timed_read(size, tmp, timeout) or return buf # truncated buf << tmp end -- cgit v1.2.3-24-ge0c7