From 9593429f95643132159fa9883df7d5d30228e67c Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 10 Oct 2021 12:01:16 +0200 Subject: [PATCH] utils: trim(): Take string_view --- utils.cpp | 3 +-- utils.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/utils.cpp b/utils.cpp index 111bccc..bf7ffa5 100644 --- a/utils.cpp +++ b/utils.cpp @@ -182,10 +182,9 @@ std::string utils::toISODate(time_t t) 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 view = str; auto n = view.find_first_not_of(chars); if(n != std::string_view::npos) { diff --git a/utils.h b/utils.h index 40bea55..4e08569 100644 --- a/utils.h +++ b/utils.h @@ -93,7 +93,7 @@ template inline std::string toString(const T &v) return std::string(v.begin(), v.end()); } -std::string trim(const std::string &str); +std::string trim(std::string_view view); } // namespace utils #endif