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 /Tests/RunCMake | |
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 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp index ba77679..dcaa4f2 100644 --- a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp +++ b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp @@ -32,14 +32,14 @@ void compare(const char* refName, const char* testName) // trailing null to the string that we need to strip before testing for a // trailing space. if (refLine.size() && refLine[refLine.size() - 1] == 0) { - refLine = refLine.substr(0, refLine.size() - 1); + refLine.resize(refLine.size() - 1); } if (testLine.size() && testLine[testLine.size() - 1] == 0) { - testLine = testLine.substr(0, testLine.size() - 1); + testLine.resize(testLine.size() - 1); } // The reference files never have trailing spaces: if (testLine.size() && testLine[testLine.size() - 1] == ' ') { - testLine = testLine.substr(0, testLine.size() - 1); + testLine.resize(testLine.size() - 1); } if (refLine != testLine) { std::cout << "Ref and test are not the same:\n Ref: \"" << refLine |