From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id D33371F62D; Tue, 19 Jun 2018 03:57:16 +0000 (UTC) From: Eric Wong To: mogilefs-client-public@bogomips.org Cc: Eric Wong Subject: [PATCH 2/3] socket/pure_ruby: favor String#clear if available Date: Tue, 19 Jun 2018 03:57:14 +0000 Message-Id: <20180619035715.13614-3-e@80x24.org> In-Reply-To: <20180619035715.13614-1-e@80x24.org> References: <20180619035715.13614-1-e@80x24.org> List-Id: 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 @@ def timed_peek(len, dst, timeout = 5) 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 -- EW