summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestScriptHandler.cxx
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2020-03-21 11:51:46 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2020-03-23 21:41:44 (GMT)
commitef778d77e0795ecba8af55a6984ad5fa5f44377a (patch)
treef2256f9fac53cc2be8840bc69cf1f8feb32c17f6 /Source/CTest/cmCTestScriptHandler.cxx
parent77616f46817b6527c7e515de547625e554df21f9 (diff)
downloadCMake-ef778d77e0795ecba8af55a6984ad5fa5f44377a.zip
CMake-ef778d77e0795ecba8af55a6984ad5fa5f44377a.tar.gz
CMake-ef778d77e0795ecba8af55a6984ad5fa5f44377a.tar.bz2
replace std::string::substr() with operations that do not allocate memory
Modify the original string instead of creating a new copy with substr() when it is not used for anything else afterwards.
Diffstat (limited to 'Source/CTest/cmCTestScriptHandler.cxx')
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 5be9332..4fa4dc0 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -284,12 +284,14 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
// if the argument has a , in it then it needs to be broken into the fist
// argument (which is the script) and the second argument which will be
// passed into the scripts as S_ARG
- std::string script = total_script_arg;
+ std::string script;
std::string script_arg;
const std::string::size_type comma_pos = total_script_arg.find(',');
if (comma_pos != std::string::npos) {
script = total_script_arg.substr(0, comma_pos);
script_arg = total_script_arg.substr(comma_pos + 1);
+ } else {
+ script = total_script_arg;
}
// make sure the file exists
if (!cmSystemTools::FileExists(script)) {