QElapsedTimer: port some restart() calls to start()
...when the return value is unused. The code should already be safe from restart()'s preconditions: either the timer is explicitly checked for validity before the call, or we can reason about the code (in testlib, the functions are called after the one that starts the timer, making it valid). Therefore, this is just a "cosmetic" cleanup (and a super-micro-optimization), but Marc doesn't want to think about the qtestlib changes and says to pick it all the way, "just in case". Pick-to: 6.9 6.8 6.5 Change-Id: I73cf287ce1314fc3626734ec64ddf5884afe3383 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
34f993b7f5
commit
baffc8e47d
@ -1171,7 +1171,7 @@ void QNetworkReplyHttpImplPrivate::replyDownloadData(QByteArray d)
|
||||
if (downloadProgressSignalChoke.isValid() &&
|
||||
downloadProgressSignalChoke.elapsed() >= progressSignalInterval
|
||||
&& (!decompressHelper.isValid() || decompressHelper.isCountingBytes())) {
|
||||
downloadProgressSignalChoke.restart();
|
||||
downloadProgressSignalChoke.start();
|
||||
emit q->downloadProgress(bytesDownloaded, totalSizeOpt.value_or(-1));
|
||||
}
|
||||
}
|
||||
@ -1504,7 +1504,7 @@ void QNetworkReplyHttpImplPrivate::replyDownloadProgressSlot(qint64 bytesReceive
|
||||
emit q->readyRead();
|
||||
if (downloadProgressSignalChoke.isValid() &&
|
||||
downloadProgressSignalChoke.elapsed() >= progressSignalInterval) {
|
||||
downloadProgressSignalChoke.restart();
|
||||
downloadProgressSignalChoke.start();
|
||||
emit q->downloadProgress(bytesDownloaded, bytesTotal);
|
||||
}
|
||||
}
|
||||
@ -1942,7 +1942,7 @@ void QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead()
|
||||
|
||||
if (downloadProgressSignalChoke.isValid() &&
|
||||
downloadProgressSignalChoke.elapsed() >= progressSignalInterval) {
|
||||
downloadProgressSignalChoke.restart();
|
||||
downloadProgressSignalChoke.start();
|
||||
emit q->downloadProgress(bytesDownloaded, totalSizeOpt.value_or(-1));
|
||||
}
|
||||
}
|
||||
@ -2088,10 +2088,8 @@ void QNetworkReplyHttpImplPrivate::emitReplyUploadProgress(qint64 bytesSent, qin
|
||||
if (bytesSent != bytesTotal && uploadProgressSignalChoke.elapsed() < progressSignalInterval) {
|
||||
return;
|
||||
}
|
||||
uploadProgressSignalChoke.restart();
|
||||
} else {
|
||||
uploadProgressSignalChoke.start();
|
||||
}
|
||||
uploadProgressSignalChoke.start();
|
||||
}
|
||||
emit q->uploadProgress(bytesSent, bytesTotal);
|
||||
}
|
||||
|
@ -391,10 +391,8 @@ void QNetworkReplyImplPrivate::emitUploadProgress(qint64 bytesSent, qint64 bytes
|
||||
if (bytesSent != bytesTotal && uploadProgressSignalChoke.elapsed() < progressSignalInterval) {
|
||||
return;
|
||||
}
|
||||
uploadProgressSignalChoke.restart();
|
||||
} else {
|
||||
uploadProgressSignalChoke.start();
|
||||
}
|
||||
uploadProgressSignalChoke.start();
|
||||
}
|
||||
|
||||
pauseNotificationHandling();
|
||||
|
@ -142,7 +142,7 @@ void QJUnitTestLogger::enterTestCase(const char *name)
|
||||
|
||||
++testCounter;
|
||||
|
||||
elapsedTestcaseTime.restart();
|
||||
elapsedTestcaseTime.start();
|
||||
}
|
||||
|
||||
void QJUnitTestLogger::enterTestData(QTestData *)
|
||||
@ -158,7 +158,7 @@ void QJUnitTestLogger::enterTestData(QTestData *)
|
||||
currentTestCase->attribute(QTest::AI_Name));
|
||||
name->setPair(QTest::AI_Name, testIdentifier.data());
|
||||
lastTestFunction = QTestResult::currentTestFunction();
|
||||
elapsedTestcaseTime.restart();
|
||||
elapsedTestcaseTime.start();
|
||||
} else {
|
||||
// Create new test cases for remaining test data
|
||||
leaveTestCase();
|
||||
|
@ -320,7 +320,7 @@ namespace QTest {
|
||||
|
||||
void QTestLog::enterTestFunction(const char* function)
|
||||
{
|
||||
elapsedFunctionTime.restart();
|
||||
elapsedFunctionTime.start();
|
||||
if (printAvailableTags)
|
||||
return;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user