Browse Source

cmDocumentation: Optimize `std::ostream::operator<<()` calls

Alex Turbov 3 years ago
parent
commit
f074e2bd49
2 changed files with 19 additions and 19 deletions
  1. 8 8
      Source/cmDocumentation.cxx
  2. 11 11
      Source/cmDocumentationFormatter.cxx

+ 8 - 8
Source/cmDocumentation.cxx

@@ -469,7 +469,7 @@ void cmDocumentation::PrintNames(std::ostream& os, std::string const& pattern)
   }
   std::sort(names.begin(), names.end());
   for (std::string const& n : names) {
-    os << n << "\n";
+    os << n << '\n';
   }
 }
 
@@ -505,7 +505,7 @@ bool cmDocumentation::PrintHelpOneManual(std::ostream& os)
   // Argument was not a manual.  Complain.
   os << "Argument \"" << this->CurrentArgument
      << "\" to --help-manual is not an available manual.  "
-     << "Use --help-manual-list to see all available manuals.\n";
+        "Use --help-manual-list to see all available manuals.\n";
   return false;
 }
 
@@ -524,7 +524,7 @@ bool cmDocumentation::PrintHelpOneCommand(std::ostream& os)
   // Argument was not a command.  Complain.
   os << "Argument \"" << this->CurrentArgument
      << "\" to --help-command is not a CMake command.  "
-     << "Use --help-command-list to see all commands.\n";
+        "Use --help-command-list to see all commands.\n";
   return false;
 }
 
@@ -557,7 +557,7 @@ bool cmDocumentation::PrintHelpListModules(std::ostream& os)
   }
   std::sort(modules.begin(), modules.end());
   for (std::string const& m : modules) {
-    os << m << "\n";
+    os << m << '\n';
   }
   return true;
 }
@@ -571,7 +571,7 @@ bool cmDocumentation::PrintHelpOneProperty(std::ostream& os)
   // Argument was not a property.  Complain.
   os << "Argument \"" << this->CurrentArgument
      << "\" to --help-property is not a CMake property.  "
-     << "Use --help-property-list to see all properties.\n";
+        "Use --help-property-list to see all properties.\n";
   return false;
 }
 
@@ -620,7 +620,7 @@ bool cmDocumentation::PrintHelpOneVariable(std::ostream& os)
   // Argument was not a variable.  Complain.
   os << "Argument \"" << this->CurrentArgument
      << "\" to --help-variable is not a defined variable.  "
-     << "Use --help-variable-list to see all defined variables.\n";
+        "Use --help-variable-list to see all defined variables.\n";
   return false;
 }
 
@@ -689,7 +689,7 @@ bool cmDocumentation::PrintOldCustomModules(std::ostream& os)
   } else if ((ext.length() == 2) && (ext[1] >= '1') && (ext[1] <= '9')) {
     /* clang-format off */
     os <<
-      ".TH " << name << " " << ext[1] << " \"" <<
+      ".TH " << name << ' ' << ext[1] << " \"" <<
       cmSystemTools::GetCurrentDateTime("%B %d, %Y") <<
       "\" \"cmake " << cmVersion::GetCMakeVersion() << "\"\n"
       ".SH NAME\n"
@@ -702,7 +702,7 @@ bool cmDocumentation::PrintOldCustomModules(std::ostream& os)
       ;
     /* clang-format on */
   } else {
-    os << name << "\n\n" << summary << "\n" << detail;
+    os << name << "\n\n" << summary << '\n' << detail;
   }
   return true;
 }

+ 11 - 11
Source/cmDocumentationFormatter.cxx

@@ -67,7 +67,7 @@ void cmDocumentationFormatter::PrintPreformatted(std::ostream& os,
       newline = true;
     }
   }
-  os << "\n";
+  os << '\n';
 }
 
 void cmDocumentationFormatter::PrintParagraph(std::ostream& os,
@@ -75,7 +75,7 @@ void cmDocumentationFormatter::PrintParagraph(std::ostream& os,
 {
   os << this->TextIndent;
   this->PrintColumn(os, text);
-  os << "\n";
+  os << '\n';
 }
 
 void cmDocumentationFormatter::SetIndent(const char* indent)
@@ -111,7 +111,7 @@ void cmDocumentationFormatter::PrintColumn(std::ostream& os, const char* text)
             os << "  ";
             column += 2;
           } else {
-            os << " ";
+            os << ' ';
             column += 1;
           }
         } else {
@@ -127,7 +127,7 @@ void cmDocumentationFormatter::PrintColumn(std::ostream& os, const char* text)
 
       if (*r == '\n') {
         // Text provided a newline.  Start a new line.
-        os << "\n";
+        os << '\n';
         ++r;
         column = 0;
         firstLine = false;
@@ -137,7 +137,7 @@ void cmDocumentationFormatter::PrintColumn(std::ostream& os, const char* text)
       }
     } else {
       // Word does not fit on this line.  Start a new line.
-      os << "\n";
+      os << '\n';
       firstLine = false;
       if (r > l) {
         os << this->TextIndent;
@@ -160,7 +160,7 @@ void cmDocumentationFormatter::PrintColumn(std::ostream& os, const char* text)
 void cmDocumentationFormatter::PrintSection(
   std::ostream& os, cmDocumentationSection const& section)
 {
-  os << section.GetName() << "\n";
+  os << section.GetName() << '\n';
 
   const std::vector<cmDocumentationEntry>& entries = section.GetEntries();
   for (cmDocumentationEntry const& entry : entries) {
@@ -169,20 +169,20 @@ void cmDocumentationFormatter::PrintSection(
       this->TextIndent = "                                 ";
       int align = static_cast<int>(strlen(this->TextIndent)) - 4;
       for (int i = static_cast<int>(entry.Name.size()); i < align; ++i) {
-        os << " ";
+        os << ' ';
       }
       if (entry.Name.size() > strlen(this->TextIndent) - 4) {
-        os << "\n";
+        os << '\n';
         os.write(this->TextIndent, strlen(this->TextIndent) - 2);
       }
       os << "= ";
       this->PrintColumn(os, entry.Brief.c_str());
-      os << "\n";
+      os << '\n';
     } else {
-      os << "\n";
+      os << '\n';
       this->TextIndent = "";
       this->PrintFormatted(os, entry.Brief.c_str());
     }
   }
-  os << "\n";
+  os << '\n';
 }