Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2688,11 +2688,17 @@ def header_convert(name = nil, &converter)
# end
def each(&block)
return to_enum(__method__) unless block_given?
begin
while true
yield(parser_enumerator.next)
# Avoid per-row Enumerator#next (Fiber-backed, slow on JRuby) unless a
# #shift/#peek has already started pull-based iteration.
if @parser_enumerator.nil?
parser.parse(&block)
else
begin
while true
yield(@parser_enumerator.next)
end
rescue StopIteration
end
rescue StopIteration
end
end

Expand Down
Loading