mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-28 18:09:42 -05:00
use std::string::rfind() instead of open coding it
While at it avoid creating a new string.
This commit is contained in:
@@ -386,24 +386,20 @@ int cmCTestBuildHandler::ProcessHandler()
|
||||
if (this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20) {
|
||||
std::string srcdir =
|
||||
this->CTest->GetCTestConfiguration("SourceDirectory") + "/";
|
||||
for (cc = srcdir.size() - 2; cc > 0; cc--) {
|
||||
if (srcdir[cc] == '/') {
|
||||
srcdir = srcdir.substr(0, cc + 1);
|
||||
break;
|
||||
}
|
||||
cc = srcdir.rfind('/', srcdir.size() - 2);
|
||||
if (cc != std::string::npos) {
|
||||
srcdir.resize(cc + 1);
|
||||
this->SimplifySourceDir = std::move(srcdir);
|
||||
}
|
||||
this->SimplifySourceDir = srcdir;
|
||||
}
|
||||
if (this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20) {
|
||||
std::string bindir =
|
||||
this->CTest->GetCTestConfiguration("BuildDirectory") + "/";
|
||||
for (cc = bindir.size() - 2; cc > 0; cc--) {
|
||||
if (bindir[cc] == '/') {
|
||||
bindir = bindir.substr(0, cc + 1);
|
||||
break;
|
||||
}
|
||||
cc = bindir.rfind('/', bindir.size() - 2);
|
||||
if (cc != std::string::npos) {
|
||||
bindir.resize(cc + 1);
|
||||
this->SimplifyBuildDir = std::move(bindir);
|
||||
}
|
||||
this->SimplifyBuildDir = bindir;
|
||||
}
|
||||
|
||||
// Ok, let's do the build
|
||||
|
||||
Reference in New Issue
Block a user