summaryrefslogtreecommitdiffstats
path: root/src/tools/androiddeployqt/main.cpp
diff options
context:
space:
mode:
authorRym Bouabid <[email protected]>2024-08-13 12:42:01 +0200
committerRym Bouabid <[email protected]>2024-09-20 11:49:19 +0200
commitf0aa391ef89a393221d77d5ad3c1616a4727f11a (patch)
treecf6b5a1b3d0a5644c1989ba0fc5ed26d093c0bd4 /src/tools/androiddeployqt/main.cpp
parent69e6ae1670faaa901e5ad06a79fa330761f1af36 (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/tools/androiddeployqt/main.cpp')
-rw-r--r--src/tools/androiddeployqt/main.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp
index 98324ab5b25..cf13c5e781a 100644
--- a/src/tools/androiddeployqt/main.cpp
+++ b/src/tools/androiddeployqt/main.cpp
@@ -2837,8 +2837,9 @@ QStringList getLibraryProjectsInOutputFolder(const Options &options)
QFile file(options.outputDirectory + "/project.properties"_L1);
if (file.open(QIODevice::ReadOnly)) {
- while (!file.atEnd()) {
- QByteArray line = file.readLine().trimmed();
+ QByteArray lineArray;
+ while (file.readLineInto(&lineArray)) {
+ QByteArrayView line = QByteArrayView(lineArray).trimmed();
if (line.startsWith("android.library.reference")) {
int equalSignIndex = line.indexOf('=');
if (equalSignIndex >= 0) {
@@ -2913,8 +2914,8 @@ static bool mergeGradleProperties(const QString &path, GradleProperties properti
QFile oldFile(oldPathStr);
if (oldFile.open(QIODevice::ReadOnly)) {
- while (!oldFile.atEnd()) {
- QByteArray line(oldFile.readLine());
+ QByteArray line;
+ while (oldFile.readLineInto(&line)) {
QList<QByteArray> prop(line.split('='));
if (prop.size() > 1) {
GradleProperties::iterator it = properties.find(prop.at(0).trimmed());