diff options
author | Eric Wong <e@80x24.org> | 2014-10-18 10:57:24 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2014-10-18 10:57:24 +0000 |
commit | 0f2b4369192946ecf8ab22b1c2eacd92ff595312 (patch) | |
tree | 8dea8bf4aa46bf245827498b9070a8035de200ac /lib | |
parent | 62696b88ec5fbe5542af7affdaea546dcbbf0508 (diff) | |
download | yahns-0f2b4369192946ecf8ab22b1c2eacd92ff595312.tar.gz |
String#clear has a simpler dispatch and requires no object allocation. The only reason we used String#replace before was because it was inherited from a Ruby 1.8-compatible project where String#clear was not available.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/yahns/stream_input.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/yahns/stream_input.rb b/lib/yahns/stream_input.rb index eea3a0a..d32ff66 100644 --- a/lib/yahns/stream_input.rb +++ b/lib/yahns/stream_input.rb @@ -50,7 +50,7 @@ class Yahns::StreamInput # :nodoc: rv << @rbuf to_read -= @rbuf.size end - @rbuf.replace('') + @rbuf.clear end rv = nil if rv.empty? && length != 0 else @@ -137,7 +137,7 @@ class Yahns::StreamInput # :nodoc: dst << @rbuf end ensure - @rbuf.replace('') + @rbuf.clear end def eof! |