summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-04-28 12:05:14 +0900
committerHiroshi Mimaki <[email protected]>2020-05-01 16:57:45 +0900
commite77e6e9d1237a6999a1e1bb6dcd2c7fa8e6187b4 (patch)
tree53d90e2f744e9e08f79d41b28bceb86baef82d49
parenta2b87c033a3239e0d9c5fce1166d2d653ab5704f (diff)
downloadmruby-e77e6e9d1237a6999a1e1bb6dcd2c7fa8e6187b4.tar.gz
mruby-e77e6e9d1237a6999a1e1bb6dcd2c7fa8e6187b4.zip
Fix `_read_buf` to be more efficient; fix #4982
The bug was introduced by #4712. The `getc' problem resurrected. It should be addressed soon.
-rw-r--r--mrbgems/mruby-io/mrblib/io.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/mrbgems/mruby-io/mrblib/io.rb b/mrbgems/mruby-io/mrblib/io.rb
index c0cfdc403..ce33f2367 100644
--- a/mrbgems/mruby-io/mrblib/io.rb
+++ b/mrbgems/mruby-io/mrblib/io.rb
@@ -170,13 +170,8 @@ class IO
end
def _read_buf
- return @buf if @buf && @buf.bytesize >= 4 # maximum UTF-8 character is 4 bytes
- @buf ||= ""
- begin
- @buf += sysread(BUF_SIZE)
- rescue EOFError => e
- raise e if @buf.empty?
- end
+ return @buf if @buf && @buf.bytesize > 0
+ sysread(BUF_SIZE, @buf)
end
def ungetc(substr)