From ba27039852c1c853e618ce36651398b65b5beee6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Tue, 23 Jan 2018 18:36:18 -0500 Subject: [PATCH] SystemToolsAppendComponents: move strings when building components All callers of this function use temporary storage for the input. Instead of copying strings, move them. --- SystemTools.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SystemTools.cxx b/SystemTools.cxx index 999beb3..6f016d2 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -3171,8 +3171,8 @@ void SystemTools::CheckTranslationPath(std::string& path) static void SystemToolsAppendComponents( std::vector<std::string>& out_components, - std::vector<std::string>::const_iterator first, - std::vector<std::string>::const_iterator last) + std::vector<std::string>::iterator first, + std::vector<std::string>::iterator last) { static const std::string up = ".."; static const std::string cur = "."; @@ -3182,7 +3182,11 @@ static void SystemToolsAppendComponents( out_components.resize(out_components.size() - 1); } } else if (!i->empty() && *i != cur) { +#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) + out_components.push_back(std::move(*i)); +#else out_components.push_back(*i); +#endif } } } -- GitLab