diff options
author | Sutou Kouhei <kou@clear-code.com> | 2022-09-08 06:19:05 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-05-25 01:44:17 +0900 |
commit | 88876f02c1050be989500090763203a36c70597b (patch) | |
tree | 4087bf99139becd61249c9ea0b0407c54979e783 /lib/csv.rb | |
parent | 73c56e06c429ca713d3b612437d2087314a1062f (diff) |
[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
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7851
Diffstat (limited to 'lib/csv.rb')
-rw-r--r-- | lib/csv.rb | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/lib/csv.rb b/lib/csv.rb index 78c3029e7b..d4dc569b83 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -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 |