summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2019-07-04 18:04:19 (GMT)
committerAlex Turbov <i.zaufi@gmail.com>2019-07-09 22:06:14 (GMT)
commitb821f9ad62d97b975255380674aaedfce296a8b8 (patch)
tree6a6cded47e71bae966932acb9cdf665b4a4ae308 /Source
parentf374ffb14b3e55bbee8e7bb0eb3e5a33ee3612f1 (diff)
downloadCMake-b821f9ad62d97b975255380674aaedfce296a8b8.zip
CMake-b821f9ad62d97b975255380674aaedfce296a8b8.tar.gz
CMake-b821f9ad62d97b975255380674aaedfce296a8b8.tar.bz2
Refactor: Optimize some stream output operations
- remove redundant `std::flush` right after `std::endl` - join some string literals Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCTest.cxx24
-rw-r--r--Source/cmMessenger.cxx3
-rw-r--r--Source/cmakemain.cxx4
3 files changed, 12 insertions, 19 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index d1226c3..63b8da4 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1098,9 +1098,10 @@ int cmCTest::RunMakeCommand(const std::string& command, std::string& output,
cmProcessOutput processOutput(encoding);
std::string strdata;
cmCTestLog(this, HANDLER_PROGRESS_OUTPUT,
- " Each . represents " << tick_len << " bytes of output"
- << std::endl
- << " " << std::flush);
+ " Each . represents " << tick_len
+ << " bytes of output\n"
+ " "
+ << std::flush);
while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) {
processOutput.DecodeText(data, length, strdata);
for (char& cc : strdata) {
@@ -1115,8 +1116,7 @@ int cmCTest::RunMakeCommand(const std::string& command, std::string& output,
if (tick % tick_line_len == 0 && tick > 0) {
cmCTestLog(this, HANDLER_PROGRESS_OUTPUT,
" Size: " << int((double(output.size()) / 1024.0) + 1)
- << "K" << std::endl
- << " " << std::flush);
+ << "K\n " << std::flush);
}
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
@@ -1324,18 +1324,14 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
if (output) {
*output += outerr;
}
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
- outerr << std::endl
- << std::flush);
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr << std::endl);
} else if (result == cmsysProcess_State_Error) {
std::string outerr = "\n*** ERROR executing: ";
outerr += cmsysProcess_GetErrorString(cp);
if (output) {
*output += outerr;
}
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
- outerr << std::endl
- << std::flush);
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr << std::endl);
}
cmsysProcess_Delete(cp);
@@ -3077,11 +3073,11 @@ void cmCTest::Log(int logType, const char* file, int line, const char* msg,
} else {
*this->Impl->OutputLogFile << cmCTestStringLogType[logType];
}
- *this->Impl->OutputLogFile << "] " << std::endl << std::flush;
+ *this->Impl->OutputLogFile << "] " << std::endl;
}
*this->Impl->OutputLogFile << msg << std::flush;
if (logType != this->Impl->OutputLogFileLastTag) {
- *this->Impl->OutputLogFile << std::endl << std::flush;
+ *this->Impl->OutputLogFile << std::endl;
this->Impl->OutputLogFileLastTag = logType;
}
}
@@ -3194,7 +3190,7 @@ void cmCTest::OutputTestErrors(std::vector<char> const& process_output)
if (!process_output.empty()) {
test_outputs.append(process_output.data(), process_output.size());
}
- cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush);
+ cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl);
}
bool cmCTest::CompressString(std::string& str)
diff --git a/Source/cmMessenger.cxx b/Source/cmMessenger.cxx
index 1d790e2..0d2b21f 100644
--- a/Source/cmMessenger.cxx
+++ b/Source/cmMessenger.cxx
@@ -100,8 +100,7 @@ void displayMessage(MessageType t, std::ostringstream& msg)
"it.";
} else if (t == MessageType::AUTHOR_ERROR) {
msg << "This error is for project developers. Use -Wno-error=dev to "
- "suppress "
- "it.";
+ "suppress it.";
}
// Add a terminating blank line.
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index a6348b3..f80829f 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -159,7 +159,7 @@ static std::string cmakemainGetStack(cmake* cm)
static void cmakemainMessageCallback(const std::string& m,
const char* /*unused*/, cmake* cm)
{
- std::cerr << m << cmakemainGetStack(cm) << std::endl << std::flush;
+ std::cerr << m << cmakemainGetStack(cm) << std::endl;
}
static void cmakemainProgressCallback(const std::string& m, float prog,
@@ -178,8 +178,6 @@ static void cmakemainProgressCallback(const std::string& m, float prog,
if ((prog < 0) || (!dir.empty())) {
std::cout << "-- " << m << dir << cmakemainGetStack(cm) << std::endl;
}
-
- std::cout.flush();
}
int main(int ac, char const* const* av)