diff options
author | Eric Wong <e@80x24.org> | 2017-01-31 01:56:36 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-01-31 01:56:36 +0000 |
commit | 464d874a17a958407d769164bd7683b9f6db38c4 (patch) | |
tree | d98a52cfc086125acf7af4a391c05d54f76f85f4 /lib/mogilefs/socket_common.rb | |
parent | a251cba43a0c24a7aa04b1baf3421ba6f7bf6cda (diff) | |
download | mogilefs-client-464d874a17a958407d769164bd7683b9f6db38c4.tar.gz |
This should reduce the amount of garbage we produce and keep the process leaner and meaner.
Diffstat (limited to 'lib/mogilefs/socket_common.rb')
-rw-r--r-- | lib/mogilefs/socket_common.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/mogilefs/socket_common.rb b/lib/mogilefs/socket_common.rb index d430068..886c738 100644 --- a/lib/mogilefs/socket_common.rb +++ b/lib/mogilefs/socket_common.rb @@ -23,18 +23,17 @@ module MogileFS::SocketCommon "request truncated (sent #{written} expected #{expect} timeout=#{timeout})" end - SEP_RE = /\A(.*?#{Regexp.escape("\n")})/ def timed_gets(timeout = 5) unless defined?(@rbuf) && @rbuf @rbuf = timed_read(1024, "", timeout) or return # EOF end begin - @rbuf.sub!(SEP_RE, "") and return $1 + @rbuf.sub!(/\A(.*\n)/o, "".freeze) and return $1 tmp ||= "" if timed_read(1024, tmp, timeout) @rbuf << tmp else - # EOF, return the last buffered bit even without SEP_RE matching + # EOF, return the last buffered bit even without separatar matching # (not ideal for MogileFS, this is an error) return @rbuf.empty? ? nil : @rbuf.slice!(0, @rbuf.size) end |