diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-04-28 12:05:14 +0900 |
|---|---|---|
| committer | Hiroshi Mimaki <[email protected]> | 2020-05-01 16:57:45 +0900 |
| commit | e77e6e9d1237a6999a1e1bb6dcd2c7fa8e6187b4 (patch) | |
| tree | 53d90e2f744e9e08f79d41b28bceb86baef82d49 | |
| parent | a2b87c033a3239e0d9c5fce1166d2d653ab5704f (diff) | |
| download | mruby-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.rb | 9 |
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) |
