forked from qt-creator/qt-creator
Utils: Minor cleanup in SynchronousProcess
* Do not reserve QString before replacing it with another * Do not append \n when there's only stdout Change-Id: If75eade473949437a4b5fea2ac0153fa2853b3c8 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
7a40d31598
commit
fae08f5c7c
@@ -141,9 +141,7 @@ QString SynchronousProcessResponse::exitMessage(const QString &binary, int timeo
|
|||||||
QByteArray SynchronousProcessResponse::allRawOutput() const
|
QByteArray SynchronousProcessResponse::allRawOutput() const
|
||||||
{
|
{
|
||||||
if (!rawStdOut.isEmpty() && !rawStdErr.isEmpty()) {
|
if (!rawStdOut.isEmpty() && !rawStdErr.isEmpty()) {
|
||||||
QByteArray result;
|
QByteArray result = rawStdOut;
|
||||||
result.reserve(rawStdOut.size() + rawStdErr.size() + 1);
|
|
||||||
result = rawStdOut;
|
|
||||||
if (!result.endsWith('\n'))
|
if (!result.endsWith('\n'))
|
||||||
result += '\n';
|
result += '\n';
|
||||||
result += rawStdErr;
|
result += rawStdErr;
|
||||||
@@ -157,14 +155,15 @@ QString SynchronousProcessResponse::allOutput() const
|
|||||||
const QString out = stdOut();
|
const QString out = stdOut();
|
||||||
const QString err = stdErr();
|
const QString err = stdErr();
|
||||||
|
|
||||||
QString result;
|
if (!out.isEmpty() && !err.isEmpty()) {
|
||||||
result.reserve(out.size() + err.size() + 1);
|
QString result = out;
|
||||||
result = out;
|
|
||||||
if (!result.endsWith('\n'))
|
if (!result.endsWith('\n'))
|
||||||
result += '\n';
|
result += '\n';
|
||||||
result += err;
|
result += err;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
return !out.isEmpty() ? out : err;
|
||||||
|
}
|
||||||
|
|
||||||
QString SynchronousProcessResponse::stdOut() const
|
QString SynchronousProcessResponse::stdOut() const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user