diff options
| author | Rym Bouabid <[email protected]> | 2024-08-13 12:42:01 +0200 |
|---|---|---|
| committer | Rym Bouabid <[email protected]> | 2024-09-20 11:49:19 +0200 |
| commit | f0aa391ef89a393221d77d5ad3c1616a4727f11a (patch) | |
| tree | cf6b5a1b3d0a5644c1989ba0fc5ed26d093c0bd4 /src/testlib/qbenchmarkvalgrind.cpp | |
| parent | 69e6ae1670faaa901e5ad06a79fa330761f1af36 (diff) | |
Use QIODevice::readLineInto() instead of readLine() in loops
Most of the callers of QIODevice::readLine() are reading a device line
by line in a loop. Instead, use one QByteArray and modify it in every
iteration using QIODevice::readLineInto().
Use a QByteArrayView instead of QByteArray when calling trimmed() as
it's an expensive operation.
Fixes: QTBUG-103108
Change-Id: Ic1af487a2fbf352cc21d76a41717944d034d3709
Reviewed-by: Marc Mutz <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
Diffstat (limited to 'src/testlib/qbenchmarkvalgrind.cpp')
| -rw-r--r-- | src/testlib/qbenchmarkvalgrind.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/testlib/qbenchmarkvalgrind.cpp b/src/testlib/qbenchmarkvalgrind.cpp index 1663c5d28d2..33479f135d7 100644 --- a/src/testlib/qbenchmarkvalgrind.cpp +++ b/src/testlib/qbenchmarkvalgrind.cpp @@ -60,8 +60,8 @@ qint64 QBenchmarkValgrindUtils::extractResult(const QString &fileName) Q_UNUSED(openOk); std::optional<qint64> val = std::nullopt; - while (!file.atEnd()) { - const QByteArray line = file.readLine(); + QByteArray line; + while (file.readLineInto(&line)) { constexpr QByteArrayView tag = "summary: "; if (line.startsWith(tag)) { const auto maybeNumber = line.data() + tag.size(); |
