From f0aa391ef89a393221d77d5ad3c1616a4727f11a Mon Sep 17 00:00:00 2001 From: Rym Bouabid Date: Tue, 13 Aug 2024 12:42:01 +0200 Subject: 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 Reviewed-by: Thiago Macieira --- src/tools/windeployqt/utils.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/tools/windeployqt/utils.cpp') diff --git a/src/tools/windeployqt/utils.cpp b/src/tools/windeployqt/utils.cpp index 25b4a9788b2..ea32346c65f 100644 --- a/src/tools/windeployqt/utils.cpp +++ b/src/tools/windeployqt/utils.cpp @@ -225,10 +225,9 @@ QMap queryQtPaths(const QString &qtpathsBinary, QString *error } QFile qconfigPriFile(result.value(QStringLiteral("QT_HOST_DATA")) + QStringLiteral("/mkspecs/qconfig.pri")); if (qconfigPriFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - while (true) { - const QByteArray line = qconfigPriFile.readLine(); - if (line.isEmpty()) - break; + QByteArray lineArray; + while (qconfigPriFile.readLineInto(&lineArray)) { + QByteArrayView line = QByteArrayView(lineArray); if (line.startsWith("QT_LIBINFIX")) { const int pos = line.indexOf('='); if (pos >= 0) { -- cgit v1.2.3