From e72eb190bbefd628479f51fbb504be14eeb0bea2 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Fri, 4 Nov 2022 14:50:14 +0200 Subject: Use QFileInfo::exists() as that is documented to be faster Change-Id: I413669860334d96de684c1c32962a33166ac6c7c Reviewed-by: Arttu Tarkiainen --- src/libs/installer/createlinkoperation.cpp | 2 +- src/libs/installer/fileutils.cpp | 4 ++-- src/libs/installer/packagemanagercore.cpp | 2 +- src/libs/installer/packagemanagercore_p.cpp | 6 +++--- src/libs/installer/sysinfo_win.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/libs/installer') diff --git a/src/libs/installer/createlinkoperation.cpp b/src/libs/installer/createlinkoperation.cpp index 3f29367b6..65ff8fc5d 100644 --- a/src/libs/installer/createlinkoperation.cpp +++ b/src/libs/installer/createlinkoperation.cpp @@ -88,7 +88,7 @@ bool CreateLinkOperation::undoOperation() return false; } - return !QFileInfo(linkPath).exists(); + return !QFileInfo::exists(linkPath); } bool CreateLinkOperation::testOperation() diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp index ebef3495d..16502383c 100644 --- a/src/libs/installer/fileutils.cpp +++ b/src/libs/installer/fileutils.cpp @@ -371,7 +371,7 @@ bool QInstaller::setDefaultFilePermissions(QFile *file, DefaultFilePermissions p void QInstaller::copyDirectoryContents(const QString &sourceDir, const QString &targetDir) { Q_ASSERT(QFileInfo(sourceDir).isDir()); - Q_ASSERT(!QFileInfo(targetDir).exists() || QFileInfo(targetDir).isDir()); + Q_ASSERT(!QFileInfo::exists(targetDir) || QFileInfo(targetDir).isDir()); if (!QDir().mkpath(targetDir)) { throw Error(QCoreApplication::translate("QInstaller", "Cannot create directory \"%1\".") .arg(QDir::toNativeSeparators(targetDir))); @@ -402,7 +402,7 @@ void QInstaller::copyDirectoryContents(const QString &sourceDir, const QString & void QInstaller::moveDirectoryContents(const QString &sourceDir, const QString &targetDir) { Q_ASSERT(QFileInfo(sourceDir).isDir()); - Q_ASSERT(!QFileInfo(targetDir).exists() || QFileInfo(targetDir).isDir()); + Q_ASSERT(!QFileInfo::exists(targetDir) || QFileInfo(targetDir).isDir()); if (!QDir().mkpath(targetDir)) { throw Error(QCoreApplication::translate("QInstaller", "Cannot create directory \"%1\".") .arg(QDir::toNativeSeparators(targetDir))); diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 7687ce13c..3e19d6b81 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -1048,7 +1048,7 @@ bool PackageManagerCore::isFileExtensionRegistered(const QString &extension) con */ bool PackageManagerCore::fileExists(const QString &filePath) const { - return QFileInfo(filePath).exists(); + return QFileInfo::exists(filePath); } /*! diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 368f9aaae..cbf7813a7 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -1404,7 +1404,7 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper bool newBinaryWritten = false; QString mtName = maintenanceToolName(); const QString installerBaseBinary = replaceVariables(m_installerBaseBinaryUnreplaced); - if (!installerBaseBinary.isEmpty() && QFileInfo(installerBaseBinary).exists()) { + if (!installerBaseBinary.isEmpty() && QFileInfo::exists(installerBaseBinary)) { qCDebug(QInstaller::lcInstallerInstallLog) << "Got a replacement installer base binary:" << installerBaseBinary; if (QInstaller::isInBundle(installerBaseBinary)) { @@ -1455,7 +1455,7 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper } } m_installerBaseBinaryUnreplaced.clear(); - } else if (!installerBaseBinary.isEmpty() && !QFileInfo(installerBaseBinary).exists()) { + } else if (!installerBaseBinary.isEmpty() && !QFileInfo::exists(installerBaseBinary)) { qCWarning(QInstaller::lcInstallerInstallLog) << "The current maintenance tool could not be updated." << installerBaseBinary << "does not exist. Please fix the \"setInstallerBaseBinary" "()\" call in your script."; @@ -2177,7 +2177,7 @@ bool PackageManagerCorePrivate::runOfflineGenerator() m_core->downloadNeededArchives(double(1)); const QString installerBaseReplacement = replaceVariables(m_offlineBaseBinaryUnreplaced); - if (!installerBaseReplacement.isEmpty() && QFileInfo(installerBaseReplacement).exists()) { + if (!installerBaseReplacement.isEmpty() && QFileInfo::exists(installerBaseReplacement)) { qCDebug(QInstaller::lcInstallerInstallLog) << "Got a replacement installer base binary:" << offlineBinaryTempName; diff --git a/src/libs/installer/sysinfo_win.cpp b/src/libs/installer/sysinfo_win.cpp index e6c2a0be8..e74eb1d4e 100644 --- a/src/libs/installer/sysinfo_win.cpp +++ b/src/libs/installer/sysinfo_win.cpp @@ -150,7 +150,7 @@ QList mountedVolumes() bool pathIsOnLocalDevice(const QString &path) { - if (!QFileInfo(path).exists()) + if (!QFileInfo::exists(path)) return false; if (path.startsWith(QLatin1String("//"))) -- cgit v1.2.3