From cb3723b54c6e66cb51649e812ab021618e19e194 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 5 Feb 2023 17:27:39 +0300 Subject: [PATCH] vstd: pass separators and input by reference It removes many cases of redundnant string copying --- include/vstd/StringUtils.h | 4 ++-- lib/vstd/StringUtils.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/vstd/StringUtils.h b/include/vstd/StringUtils.h index b6d3ac8e4..181f1f9a6 100644 --- a/include/vstd/StringUtils.h +++ b/include/vstd/StringUtils.h @@ -5,8 +5,8 @@ VCMI_LIB_NAMESPACE_BEGIN namespace vstd { - DLL_LINKAGE std::vector split(std::string s, std::string separators); - DLL_LINKAGE std::pair splitStringToPair(std::string input, char separator); + DLL_LINKAGE std::vector split(std::string s, const std::string& separators); + DLL_LINKAGE std::pair splitStringToPair(const std::string& input, char separator); } diff --git a/lib/vstd/StringUtils.cpp b/lib/vstd/StringUtils.cpp index 51499078c..3d86609f8 100644 --- a/lib/vstd/StringUtils.cpp +++ b/lib/vstd/StringUtils.cpp @@ -6,14 +6,14 @@ VCMI_LIB_NAMESPACE_BEGIN namespace vstd { - DLL_LINKAGE std::vector split(std::string s, std::string separators) + DLL_LINKAGE std::vector split(std::string s, const std::string& separators) { std::vector result; boost::split(result, s, boost::is_any_of(separators)); return result; } - DLL_LINKAGE std::pair splitStringToPair(std::string input, char separator) + DLL_LINKAGE std::pair splitStringToPair(const std::string& input, char separator) { std::pair ret; size_t splitPos = input.find(separator);