From c9077a28044b32799dfd512620d25cb3cba0c6c4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 19 Jun 2018 03:57:14 +0000 Subject: socket/pure_ruby: favor String#clear if available String#replace keeps garbage around a bit longer, so it's not always the better option. cf. http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/86983 https://public-inbox.org/ruby-core/20180511033641.GA4459@dcvr/ --- lib/mogilefs/socket/pure_ruby.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mogilefs/socket/pure_ruby.rb b/lib/mogilefs/socket/pure_ruby.rb index 59e43e1..acbbaca 100644 --- a/lib/mogilefs/socket/pure_ruby.rb +++ b/lib/mogilefs/socket/pure_ruby.rb @@ -42,7 +42,7 @@ class MogileFS::Socket < Socket rescue Errno::EAGAIN wait(timeout) or unreadable_socket!(timeout) rescue EOFError - dst.replace("") + dst.respond_to?(:clear) ? dst.clear : dst.replace("") return end while true rescue EOFError -- cgit v1.2.3-24-ge0c7