From e5bcb4844d71b833d62aedcca3829f44b505dbb0 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 17 Feb 2012 14:16:55 +0100 Subject: No need to stat with QFile::exists before QFile::open, for reading. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I14ca7f8a377bca39004defc96d69d62c151181f5 Reviewed-by: João Abecasis Reviewed-by: Jeremy Katz --- src/corelib/io/qstandardpaths_unix.cpp | 2 +- src/plugins/bearer/connman/qconnmanengine.cpp | 4 ++-- src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp | 4 ++-- src/widgets/styles/qgtkstyle_p.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index 6057c26e0d..62c846738e 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -137,7 +137,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) if (xdgConfigHome.isEmpty()) xdgConfigHome = QDir::homePath() + QLatin1String("/.config"); QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs")); - if (file.exists() && file.open(QIODevice::ReadOnly)) { + if (file.open(QIODevice::ReadOnly)) { QHash lines; QTextStream stream(&file); // Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop" diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index 1a874a92b7..0e54668394 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -255,7 +255,7 @@ quint64 QConnmanEngine::bytesWritten(const QString &id) quint64 result = 0; QString devFile = getInterfaceFromId(id); QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes"); - if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&tx); in >> result; tx.close(); @@ -270,7 +270,7 @@ quint64 QConnmanEngine::bytesReceived(const QString &id) quint64 result = 0; QString devFile = getInterfaceFromId(id); QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes"); - if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (rx.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&rx); in >> result; rx.close(); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index fd79cff484..a71a241ea6 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -837,7 +837,7 @@ quint64 QNetworkManagerEngine::bytesWritten(const QString &id) quint64 result = Q_UINT64_C(0); QFile tx(devFile); - if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&tx); in >> result; tx.close(); @@ -865,7 +865,7 @@ quint64 QNetworkManagerEngine::bytesReceived(const QString &id) quint64 result = Q_UINT64_C(0); QFile tx(devFile); - if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&tx); in >> result; tx.close(); diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp index 40ad9f2a95..18e120a4eb 100644 --- a/src/widgets/styles/qgtkstyle_p.cpp +++ b/src/widgets/styles/qgtkstyle_p.cpp @@ -661,7 +661,7 @@ QString QGtkStylePrivate::getThemeName() foreach (const QString &rcPath, paths) { if (!rcPath.isEmpty()) { QFile rcFile(rcPath); - if (rcFile.exists() && rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&rcFile); while(!in.atEnd()) { QString line = in.readLine(); -- cgit v1.2.3