From bb9071e9e700e1a00230baa717401a1b4a05cd78 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 20 Oct 2024 03:53:21 +0400 Subject: [PATCH] cmDocumentationFormatter.cxx: Move padding string creation out of loop --- Source/cmDocumentationFormatter.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx index b85b2f5567..310966fea8 100644 --- a/Source/cmDocumentationFormatter.cxx +++ b/Source/cmDocumentationFormatter.cxx @@ -126,6 +126,8 @@ void cmDocumentationFormatter::PrintColumn(std::ostream& os, const std::ptrdiff_t width = this->TextWidth - this->TextIndent; std::ptrdiff_t column = 0; + const auto padding = std::string(this->TextIndent, ' '); + // Loop until the end of the text. for (const char *l = text.c_str(), *r = skipToSpace(text.c_str()); *l; l = skipSpaces(r), r = skipToSpace(l)) { @@ -141,7 +143,7 @@ void cmDocumentationFormatter::PrintColumn(std::ostream& os, } else if (!firstLine && this->TextIndent) { // First word on line. Print indentation unless this is the // first line. - os << std::string(this->TextIndent, ' '); + os << padding; } // Print the word. @@ -164,7 +166,7 @@ void cmDocumentationFormatter::PrintColumn(std::ostream& os, os << '\n'; firstLine = false; if (r > l) { - os << std::string(this->TextIndent, ' '); + os << padding; os.write(l, r - l); column = r - l; newSentence = (*(r - 1) == '.');