Skip to content

Commit

Permalink
Use std::string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
megabyde committed Jun 19, 2022
1 parent cc67b29 commit 2d66a93
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
* Utility function to split a string by the delimiter
*/
inline std::vector<std::string>
split(const std::string& record, char delimiter = ',')
split(std::string_view record, char delimiter = ',')
{
std::vector<std::string> fields;

size_t begin = 0, end;
do {
end = record.find_first_of(delimiter, begin);
fields.push_back(record.substr(begin, end - begin));
fields.emplace_back(record.substr(begin, end - begin));
begin = end + 1;
} while (end != std::string::npos);

Expand Down

0 comments on commit 2d66a93

Please sign in to comment.