Skip to content

Commit 4a4034d

Browse files
authored
optimized
1 parent dc86892 commit 4a4034d

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/main/java/org/apache/commons/csv/CSVParser.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ Map<String, Integer> getHeaderMapRaw() {
732732
* @since 1.7
733733
*/
734734
public List<String> getHeaderNames() {
735-
return Collections.unmodifiableList(headers.headerNames);
735+
return headers.headerNames;
736736
}
737737

738738
/**
@@ -765,7 +765,12 @@ public long getRecordNumber() {
765765
* on parse error or input read-failure
766766
*/
767767
public List<CSVRecord> getRecords() {
768-
return stream().collect(Collectors.toList());
768+
final List<CSVRecord> records = new ArrayList<>();
769+
final Iterator<CSVRecord> iterator = iterator();
770+
while (iterator.hasNext()) {
771+
records.add(iterator.next());
772+
}
773+
return records;
769774
}
770775

771776
/**
@@ -866,7 +871,7 @@ private boolean isStrictQuoteMode() {
866871
* {@link #getRecords()}, and return an iterator to that list.
867872
* </p>
868873
* <p>
869-
* You can use {@link CSVFormat.Builder#setMaxRows(long)} to limit how many rows an Iterator produces.
874+
* You can use {@link CSVFormat.Builder#setMaxRows(long)} to limit how many rows this Iterator produces.
870875
* </p>
871876
*/
872877
@Override

0 commit comments

Comments
 (0)