vincentlaucsb / csv-parser

A high-performance, fully-featured CSV parser and serializer for modern C++.
MIT License
901 stars 150 forks source link

Feature/buffered writer #147

Closed LukasKerk closed 3 years ago

LukasKerk commented 3 years ago

The performance of the DelimWriter class can be improved by flushing only if needed. I added a template parameter to disable the flushing in the operator<<, a flush function and a destructor that performs a final flush on destruction. Because of the new parameter the aliases CSVWriter and TSVWriter had to be adapted. The default parameter are set in a way to keep their previous behaviour (flushing directly). make_csv_writer and make_tsv_writer will still return the flushing version, however there are new helper functions make_csv_writer_buffered and make_tsv_writer_buffered for creating DelimWriter objects without the auto flush. A new test was added for demonstration.

vincentlaucsb commented 3 years ago

This is a simple but great enhancement to this library. Thank you @LukasKerk for your work.