Commit 50721e9b authored by Tomoyuki Sahara's avatar Tomoyuki Sahara

Merge pull request #32 from tmtm/fix-read-create-many-objects

FIX: IO#read create a large number of objects.
parents ee347f34 9b13a59a
...@@ -194,12 +194,12 @@ class IO ...@@ -194,12 +194,12 @@ class IO
if length && (str.size + @buf.size) >= length if length && (str.size + @buf.size) >= length
len = length - str.size len = length - str.size
str += @buf[0, len] str << @buf[0, len]
@pos += len @pos += len
@buf = @buf[len, @buf.size - len] @buf = @buf[len, @buf.size - len]
break break
else else
str += @buf str << @buf
@pos += @buf.size @pos += @buf.size
@buf = '' @buf = ''
end end
...@@ -238,18 +238,18 @@ class IO ...@@ -238,18 +238,18 @@ class IO
if limit && (str.size + @buf.size) >= limit if limit && (str.size + @buf.size) >= limit
len = limit - str.size len = limit - str.size
str += @buf[0, len] str << @buf[0, len]
@pos += len @pos += len
@buf = @buf[len, @buf.size - len] @buf = @buf[len, @buf.size - len]
break break
elsif idx = @buf.index(rs) elsif idx = @buf.index(rs)
len = idx + rs.size len = idx + rs.size
str += @buf[0, len] str << @buf[0, len]
@pos += len @pos += len
@buf = @buf[len, @buf.size - len] @buf = @buf[len, @buf.size - len]
break break
else else
str += @buf str << @buf
@pos += @buf.size @pos += @buf.size
@buf = '' @buf = ''
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment