Fix _read_buf to be more efficient; fix #4982

The bug was introduced by #4712. The `getc' problem resurrected.
It should be addressed soon.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2020-04-28 12:05:14 +09:00
committed by Hiroshi Mimaki
parent a2b87c033a
commit e77e6e9d12
+2 -7
View File
@@ -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)