[ruby/csv] All Enumerable based methods consume the same lines with other methods

This may have a performance penalty. We should benchmark this.

GitHub: fix https://github.com/ruby/csv/pull/260

Reported by Lhoussaine Ghallou. Thanks!!!

https://github.com/ruby/csv/commit/acc05116c5
This commit is contained in:
Sutou Kouhei 2022-09-08 06:19:05 +09:00 committed by Nobuyoshi Nakada
parent 73c56e06c4
commit 88876f02c1
Notes: git 2023-05-24 16:44:39 +00:00

View File

@ -2592,14 +2592,7 @@ class CSV
# # Raises IOError (not opened for reading)
# csv.read
def read
rows = []
enumerator = parser_enumerator
begin
while true
rows << enumerator.next
end
rescue StopIteration
end
rows = to_a
if parser.use_headers?
Table.new(rows, headers: parser.headers)
else