cmFindBase.cxx: Optimize cmStrCat() calls

This commit is contained in:
Alex Turbov
2024-11-17 04:49:08 +04:00
parent 16a1fa9e35
commit e2c9bb7f54

View File

@@ -615,43 +615,38 @@ cmFindBaseDebugState::~cmFindBaseDebugState()
return;
}
std::string buffer =
cmStrCat(this->CommandName, " called with the following settings:\n");
buffer += cmStrCat(" VAR: ", this->FindCommand->VariableName, "\n");
buffer += cmStrCat(
" NAMES: ", cmWrap("\"", this->FindCommand->Names, "\"", "\n "),
"\n");
buffer += cmStrCat(
" Documentation: ", this->FindCommand->VariableDocumentation, "\n");
buffer += " Framework\n";
buffer += cmStrCat(" Only Search Frameworks: ",
this->FindCommand->SearchFrameworkOnly, "\n");
buffer += cmStrCat(" Search Frameworks Last: ",
this->FindCommand->SearchFrameworkLast, "\n");
buffer += cmStrCat(" Search Frameworks First: ",
this->FindCommand->SearchFrameworkFirst, "\n");
buffer += " AppBundle\n";
buffer += cmStrCat(" Only Search AppBundle: ",
this->FindCommand->SearchAppBundleOnly, "\n");
buffer += cmStrCat(" Search AppBundle Last: ",
this->FindCommand->SearchAppBundleLast, "\n");
buffer += cmStrCat(" Search AppBundle First: ",
this->FindCommand->SearchAppBundleFirst, "\n");
// clang-format off
auto buffer =
cmStrCat(
this->CommandName, " called with the following settings:"
"\n VAR: ", this->FindCommand->VariableName,
"\n NAMES: ", cmWrap('"', this->FindCommand->Names, '"', "\n "),
"\n Documentation: ", this->FindCommand->VariableDocumentation,
"\n Framework"
"\n Only Search Frameworks: ", this->FindCommand->SearchFrameworkOnly,
"\n Search Frameworks Last: ", this->FindCommand->SearchFrameworkLast,
"\n Search Frameworks First: ", this->FindCommand->SearchFrameworkFirst,
"\n AppBundle"
"\n Only Search AppBundle: ", this->FindCommand->SearchAppBundleOnly,
"\n Search AppBundle Last: ", this->FindCommand->SearchAppBundleLast,
"\n Search AppBundle First: ", this->FindCommand->SearchAppBundleFirst,
"\n"
);
// clang-format on
if (this->FindCommand->NoDefaultPath) {
buffer += " NO_DEFAULT_PATH Enabled\n";
} else {
// clang-format off
buffer += cmStrCat(
" CMAKE_FIND_USE_CMAKE_PATH: ", !this->FindCommand->NoCMakePath, "\n",
" CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: ",
!this->FindCommand->NoCMakeEnvironmentPath, "\n",
" CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: ",
!this->FindCommand->NoSystemEnvironmentPath, "\n",
" CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: ",
!this->FindCommand->NoCMakeSystemPath, "\n",
" CMAKE_FIND_USE_INSTALL_PREFIX: ",
!this->FindCommand->NoCMakeInstallPath, "\n");
" CMAKE_FIND_USE_CMAKE_PATH: ", !this->FindCommand->NoCMakePath,
"\n CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: ", !this->FindCommand->NoCMakeEnvironmentPath,
"\n CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: ", !this->FindCommand->NoSystemEnvironmentPath,
"\n CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: ", !this->FindCommand->NoCMakeSystemPath,
"\n CMAKE_FIND_USE_INSTALL_PREFIX: ", !this->FindCommand->NoCMakeInstallPath,
"\n"
);
// clang-format on
}
buffer +=
@@ -659,14 +654,14 @@ cmFindBaseDebugState::~cmFindBaseDebugState()
for (auto const& state : this->FailedSearchLocations) {
std::string path = cmStrCat(" ", state.path);
if (!state.regexName.empty()) {
path = cmStrCat(path, "/", state.regexName);
path = cmStrCat(path, '/', state.regexName);
}
buffer += cmStrCat(path, "\n");
buffer += cmStrCat(path, '\n');
}
if (!this->FoundSearchLocation.path.empty()) {
buffer += cmStrCat("The item was found at\n ",
this->FoundSearchLocation.path, "\n");
this->FoundSearchLocation.path, '\n');
} else {
buffer += "The item was not found.\n";
}