utils: trim(): Take string_view

This commit is contained in:
Albert S. 2021-10-10 12:01:16 +02:00
parent 86ac86b83f
commit 9593429f95
2 changed files with 2 additions and 3 deletions

View File

@ -182,10 +182,9 @@ std::string utils::toISODate(time_t t)
return std::string{result}; return std::string{result};
} }
std::string utils::trim(const std::string &str) std::string utils::trim(std::string_view view)
{ {
std::string_view chars = " \t\n\r"; std::string_view chars = " \t\n\r";
std::string_view view = str;
auto n = view.find_first_not_of(chars); auto n = view.find_first_not_of(chars);
if(n != std::string_view::npos) if(n != std::string_view::npos)
{ {

View File

@ -93,7 +93,7 @@ template <class T> inline std::string toString(const T &v)
return std::string(v.begin(), v.end()); return std::string(v.begin(), v.end());
} }
std::string trim(const std::string &str); std::string trim(std::string_view view);
} // namespace utils } // namespace utils
#endif #endif