From 2697d432a4c271f1cd6b701799842688c0e4f85e Mon Sep 17 00:00:00 2001 From: Alex Maystrenko Date: Sat, 5 Feb 2022 20:54:06 +0100 Subject: [PATCH] ltrim and rtrim take argument by const-ref --- include/util/string.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/util/string.hpp b/include/util/string.hpp index c8c0209..24a9b2b 100644 --- a/include/util/string.hpp +++ b/include/util/string.hpp @@ -4,12 +4,12 @@ const std::string WHITESPACE = " \n\r\t\f\v"; -inline std::string ltrim(const std::string s) { +inline std::string ltrim(const std::string& s) { size_t begin = s.find_first_not_of(WHITESPACE); return (begin == std::string::npos) ? "" : s.substr(begin); } -inline std::string rtrim(const std::string s) { +inline std::string rtrim(const std::string& s) { size_t end = s.find_last_not_of(WHITESPACE); return (end == std::string::npos) ? "" : s.substr(0, end + 1); }