Commit 4ee32880 authored by Florian R. Hanke's avatar Florian R. Hanke

Use rpartition to further reduce code size.

parent 9ce61aa9
...@@ -100,14 +100,13 @@ module Pod ...@@ -100,14 +100,13 @@ module Pod
begin begin
loop do loop do
buf << input.readpartial(4096) buf << input.readpartial(4096)
loop do string, separator, buf = buf.rpartition(/[\r\n]/)
string, separator, buf = buf.partition(/[\r\n]/) output << string << separator
break if separator.empty?
output << [string, separator]
end
end end
rescue EOFError rescue EOFError
output << buf unless buf.size == 0 output << buf unless buf.size == 0
ensure
buf
end end
end end
end end
...@@ -143,10 +142,7 @@ module Pod ...@@ -143,10 +142,7 @@ module Pod
# @return [void] # @return [void]
# #
def <<(obj) def <<(obj)
value, newline = Array(obj) super
newline ||= "\n"
value = value + newline
super(value)
ensure ensure
@io << "#{ indent }#{ value }" if @io @io << "#{ indent }#{ value }" if @io
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