Просмотр исходного кода

clang-tidy: apply performance-faster-string-find fixes

Daniel Pfeifer 9 лет назад
Родитель
Сommit
cac529dd49

+ 1 - 1
Source/cmAddCustomTargetCommand.cxx

@@ -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;

+ 1 - 1
Source/cmAddExecutableCommand.cxx

@@ -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;

+ 1 - 1
Source/cmAddLibraryCommand.cxx

@@ -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;

+ 1 - 1
Source/cmAuxSourceDirectoryCommand.cxx

@@ -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);

+ 2 - 2
Source/cmFindPathCommand.cxx

@@ -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 = "";
     }

+ 1 - 1
Source/cmStringCommand.cxx

@@ -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));