mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
clang-tidy: apply performance-faster-string-find fixes
This commit is contained in:

committed by
Brad King

parent
7c9db8f813
commit
cac529dd49
@@ -154,7 +154,7 @@ bool cmAddCustomTargetCommand::InitialPass(
|
||||
bool nameOk = cmGeneratorExpression::IsValidTargetName(targetName) &&
|
||||
!cmGlobalGenerator::IsReservedTarget(targetName);
|
||||
if (nameOk) {
|
||||
nameOk = targetName.find(":") == std::string::npos;
|
||||
nameOk = targetName.find(':') == std::string::npos;
|
||||
}
|
||||
if (!nameOk) {
|
||||
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
|
||||
|
@@ -61,7 +61,7 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args,
|
||||
!cmGlobalGenerator::IsReservedTarget(exename);
|
||||
|
||||
if (nameOk && !importTarget && !isAlias) {
|
||||
nameOk = exename.find(":") == std::string::npos;
|
||||
nameOk = exename.find(':') == std::string::npos;
|
||||
}
|
||||
if (!nameOk) {
|
||||
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
|
||||
|
@@ -173,7 +173,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
|
||||
!cmGlobalGenerator::IsReservedTarget(libName);
|
||||
|
||||
if (nameOk && !importTarget && !isAlias) {
|
||||
nameOk = libName.find(":") == std::string::npos;
|
||||
nameOk = libName.find(':') == std::string::npos;
|
||||
}
|
||||
if (!nameOk) {
|
||||
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
|
||||
|
@@ -49,7 +49,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass(
|
||||
for (size_t i = 0; i < numfiles; ++i) {
|
||||
std::string file = dir.GetFile(static_cast<unsigned long>(i));
|
||||
// Split the filename into base and extension
|
||||
std::string::size_type dotpos = file.rfind(".");
|
||||
std::string::size_type dotpos = file.rfind('.');
|
||||
if (dotpos != std::string::npos) {
|
||||
std::string ext = file.substr(dotpos + 1);
|
||||
std::string base = file.substr(0, dotpos);
|
||||
|
@@ -72,7 +72,7 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file,
|
||||
{
|
||||
std::string fileName = file;
|
||||
std::string frameWorkName;
|
||||
std::string::size_type pos = fileName.find("/");
|
||||
std::string::size_type pos = fileName.find('/');
|
||||
// if there is a / in the name try to find the header as a framework
|
||||
// For example bar/foo.h would look for:
|
||||
// bar.framework/Headers/foo.h
|
||||
@@ -83,7 +83,7 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file,
|
||||
frameWorkName =
|
||||
frameWorkName.substr(0, frameWorkName.size() - fileName.size() - 1);
|
||||
// if the framework has a path in it then just use the filename
|
||||
if (frameWorkName.find("/") != frameWorkName.npos) {
|
||||
if (frameWorkName.find('/') != frameWorkName.npos) {
|
||||
fileName = file;
|
||||
frameWorkName = "";
|
||||
}
|
||||
|
@@ -342,7 +342,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
|
||||
std::vector<RegexReplacement> replacement;
|
||||
std::string::size_type l = 0;
|
||||
while (l < replace.length()) {
|
||||
std::string::size_type r = replace.find("\\", l);
|
||||
std::string::size_type r = replace.find('\\', l);
|
||||
if (r == std::string::npos) {
|
||||
r = replace.length();
|
||||
replacement.push_back(replace.substr(l, r - l));
|
||||
|
Reference in New Issue
Block a user