summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-04-28 12:05:14 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-04-28 13:57:46 +0900
commit3ce459f23a16a63973e1e0cfea299fb1ec108909 (patch)
tree59aa1530133b27fea21aed154188864bd6cfd1de
parente51923778f15c4627dea30ba29e3b3843951c260 (diff)
downloadmruby-3ce459f23a16a63973e1e0cfea299fb1ec108909.tar.gz
mruby-3ce459f23a16a63973e1e0cfea299fb1ec108909.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)