diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2020-03-21 11:51:46 (GMT) |
---|---|---|
committer | Rolf Eike Beer <eike@sf-mail.de> | 2020-03-23 21:41:44 (GMT) |
commit | ef778d77e0795ecba8af55a6984ad5fa5f44377a (patch) | |
tree | f2256f9fac53cc2be8840bc69cf1f8feb32c17f6 /Source/CTest/cmCTestGIT.cxx | |
parent | 77616f46817b6527c7e515de547625e554df21f9 (diff) | |
download | CMake-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/cmCTestGIT.cxx')
-rw-r--r-- | Source/CTest/cmCTestGIT.cxx | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 3f3c107..568b091 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -6,6 +6,7 @@ #include <cstdio> #include <cstdlib> #include <ctime> +#include <utility> #include <vector> #include "cmsys/FStream.hxx" @@ -193,7 +194,8 @@ bool cmCTestGIT::UpdateByFetchAndReset() if (line.find("\tnot-for-merge\t") == std::string::npos) { std::string::size_type pos = line.find('\t'); if (pos != std::string::npos) { - sha1 = line.substr(0, pos); + sha1 = std::move(line); + sha1.resize(pos); } } } |