Project

General

Profile

Feature #4017 » ruby_19_csv_parser_speedup.patch

Patch 2/2 - ender672 (Timothy Elliott), 11/03/2010 09:43 AM

View differences:

lib/csv.rb (working copy)
return line
when @col_sep
return line << nil
when @col_sep_quote
buf = @quote_char
next
end
break unless buf.slice!(0, @col_sep.size) == @col_sep
......
return unless @data_buf = @io.gets(@quote_char, @io_read_limit)
end
loop do
if newline = @data_buf.index(@row_sep)
break if newline == @data_buf.size - @row_sep.size
return @data_buf.slice!(0, newline + @row_sep.size)
end
case @data_buf
when @col_sep_quote, @quote_char
else
loop do
if newline = @data_buf.index(@row_sep)
break if newline == @data_buf.size - @row_sep.size
return @data_buf.slice!(0, newline + @row_sep.size)
end
break if @io.eof? || @data_buf.end_with?(@quote_char)
break if @io.eof? || @data_buf.end_with?(@quote_char)
if @field_size_limit && @data_buf.size > @field_size_limit
raise MalformedCSVError, "Field size exceeded on line #{@lineno}."
end
if @field_size_limit && @data_buf.size > @field_size_limit
raise MalformedCSVError, "Field size exceeded on line #{@lineno}."
end
@data_buf += @io.gets(@quote_char, @io_read_limit) unless align_data_buf
@data_buf += @io.gets(@quote_char, @io_read_limit) unless align_data_buf
end
end
return_buf = @data_buf
......
@field_size_limit = options.delete(:field_size_limit)
@io_read_limit = options.delete(:io_read_limit)
@nl_lf = encode_str("\r\n")
@col_sep_quote = @col_sep + @quote_char
end
#
(2-2/2)