From: Eric Wong <e@80x24.org>
To: mogilefs-client-public@bogomips.org
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH 2/3] socket/pure_ruby: favor String#clear if available
Date: Tue, 19 Jun 2018 03:57:14 +0000 [thread overview]
Message-ID: <20180619035715.13614-3-e@80x24.org> (raw)
In-Reply-To: <20180619035715.13614-1-e@80x24.org>
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
next prev parent reply other threads:[~2018-06-19 3:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-19 3:57 [PATCH 0/3] various updates Eric Wong
2018-06-19 3:57 ` [PATCH 1/3] mog: add updateclass command Eric Wong
2018-06-19 3:57 ` Eric Wong [this message]
2018-06-19 3:57 ` [PATCH 3/3] fix indentation warnings with ruby trunk Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/mogilefs-client/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180619035715.13614-3-e@80x24.org \
--to=e@80x24.org \
--cc=mogilefs-client-public@bogomips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/mogilefs-client.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).