summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <[email protected]>2025-03-17 13:38:35 +0100
committerMarc Mutz <[email protected]>2025-03-18 04:07:21 +0000
commitbaffc8e47df15190cd85705099698a72e2bdbfa0 (patch)
tree6107b91db04bf89dfdd18d4ce2c8d5fa08d043be
parent34f993b7f54d8cdf5a5820248970abf38c83157d (diff)
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 <[email protected]>
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp10
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp4
-rw-r--r--src/testlib/qjunittestlogger.cpp4
-rw-r--r--src/testlib/qtestlog.cpp2
4 files changed, 8 insertions, 12 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index cf4d5f1f4ff..11041dff127 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -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);
}
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index a82c01e14cf..3750900176f 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -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();
diff --git a/src/testlib/qjunittestlogger.cpp b/src/testlib/qjunittestlogger.cpp
index eb3c38b8b16..00110cdf496 100644
--- a/src/testlib/qjunittestlogger.cpp
+++ b/src/testlib/qjunittestlogger.cpp
@@ -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();
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp
index 9ae0728fc47..2bde5a94eca 100644
--- a/src/testlib/qtestlog.cpp
+++ b/src/testlib/qtestlog.cpp
@@ -320,7 +320,7 @@ namespace QTest {
void QTestLog::enterTestFunction(const char* function)
{
- elapsedFunctionTime.restart();
+ elapsedFunctionTime.start();
if (printAvailableTags)
return;