rapidcsv icon indicating copy to clipboard operation
rapidcsv copied to clipboard

std::string_view support

Open IlannM opened this issue 3 years ago • 2 comments

Hi i'd like to request C++17's std::string_view support for this lib. Afaik it may be faster in some situations rather than the old const std::string&

IlannM avatar Jul 04 '22 00:07 IlannM

Hi @IlannM - are you proposing the rapidcsv API to provide functions returning/accepting std::string_view, or are you referring to the internal data representation of a CSV document in the library?

I have previously done some study implementing "my own string_view" for internal data representation and I did not observe any measurable performance improvement. The reason is likely that std::string can store typical cell sizes without extra memory allocation, but I haven't investigated it further. Memory usage should be reduced though, but I'm not sure it warrants bumping the C++ requirement to 17 (nor maintaining two "backends" - one for C++11 and one for >= C++17).

d99kris avatar Jul 24 '22 12:07 d99kris

yes, I am referring to the API returning and accepting the std::string_view type.

IlannM avatar Jul 25 '22 05:07 IlannM

Thanks for clarifying.

I think the performance benefit for using std::string_view in the API's is small, given the fact that most CSV data cells are small.

I think if I eventually change rapidcsv to use string_view internally, I'll profile the performance and see if we should add such APIs.

For now I'll close this issue.

d99kris avatar Oct 08 '22 09:10 d99kris