From 2d66a933fbbb3b371150f8e42ff138eb5dddb704 Mon Sep 17 00:00:00 2001 From: Yury Bayda Date: Sat, 18 Jun 2022 23:21:14 -0700 Subject: [PATCH] Use std::string_view --- main.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.h b/main.h index 18821a4..f437081 100644 --- a/main.h +++ b/main.h @@ -7,14 +7,14 @@ * Utility function to split a string by the delimiter */ inline std::vector -split(const std::string& record, char delimiter = ',') +split(std::string_view record, char delimiter = ',') { std::vector 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);