utils: Pass by value where it makes sense

This commit is contained in:
Albert S. 2021-10-09 00:24:22 +02:00
부모 b1a8572eb6
커밋 92e7390056
2개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제

파일 보기

@ -84,7 +84,7 @@ std::string utils::urldecode(std::string_view str)
return result;
}
std::vector<std::string> utils::split(const std::string &str, char delim)
std::vector<std::string> utils::split(std::string str, char delim)
{
std::vector<std::string> result;
std::stringstream stream(str);
@ -97,7 +97,7 @@ std::vector<std::string> utils::split(const std::string &str, char delim)
}
// TODO: can easily break if we pass a regex here
std::vector<std::string> utils::split(const std::string &str, const std::string &delim)
std::vector<std::string> utils::split(std::string str, const std::string &delim)
{
std::regex regex{delim + "+"};
return split(str, regex);
@ -112,7 +112,7 @@ std::vector<std::string> utils::split(const std::string &str, std::regex &regex)
return result;
}
std::string utils::strreplace(const std::string &str, const std::string &search, const std::string &replace)
std::string utils::strreplace(std::string str, const std::string &search, const std::string &replace)
{
std::string result = str;
auto searchlength = search.length();

파일 보기

@ -11,11 +11,11 @@
namespace utils
{
std::vector<std::string> split(const std::string &str, char delim);
std::vector<std::string> split(const std::string &str, const std::string &delim);
std::vector<std::string> split(std::string str, char delim);
std::vector<std::string> split(std::string str, const std::string &delim);
std::vector<std::string> split(const std::string &str, std::regex &regex);
std::string urldecode(std::string_view str);
std::string strreplace(const std::string &str, const std::string &search, const std::string &replace);
std::string strreplace(std::string str, const std::string &search, const std::string &replace);
std::string html_xss(std::string_view str);
std::string getenv(const std::string &key);