diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-10-08 12:41:28 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2014-10-09 09:42:11 +0200 |
commit | 1cc06b2e9499b65ac30bbc667cf99e0077c48af7 (patch) | |
tree | 0d61af1521063330d71eb97a37e392e3a9e63d2f /src/corelib/io | |
parent | 1a5c0b26d062a380fef1bb038a9d96cde7556dc6 (diff) |
Don't use QStringLiteral in startsWith/endsWidth
For QLatin1String, startsWith/endsWith is overloaded, so comparing to
a latin-1 (C) string literal is efficient, since strlen() is
comparatively fast.
OTOH, QStringLiteral, when not using RVO, litters the code with
QString dtor calls, which are not inline. Worse, absent lambdas,
it even allocates memory.
So, just use QLatin1String instead.
Change-Id: I7eaf464c67b55116f970fe7f58a85f19ce4d254e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qstorageinfo_unix.cpp | 12 | ||||
-rw-r--r-- | src/corelib/io/qstorageinfo_win.cpp | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index b22358ed27..481de6ee38 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -88,12 +88,12 @@ QT_BEGIN_NAMESPACE static bool isPseudoFs(const QString &mountDir, const QByteArray &type) { - if (mountDir.startsWith(QStringLiteral("/dev")) - || mountDir.startsWith(QStringLiteral("/proc")) - || mountDir.startsWith(QStringLiteral("/run")) - || mountDir.startsWith(QStringLiteral("/sys")) - || mountDir.startsWith(QStringLiteral("/var/run")) - || mountDir.startsWith(QStringLiteral("/var/lock"))) { + if (mountDir.startsWith(QLatin1String("/dev")) + || mountDir.startsWith(QLatin1String("/proc")) + || mountDir.startsWith(QLatin1String("/run")) + || mountDir.startsWith(QLatin1String("/sys")) + || mountDir.startsWith(QLatin1String("/var/run")) + || mountDir.startsWith(QLatin1String("/var/lock"))) { return true; } #if defined(Q_OS_LINUX) diff --git a/src/corelib/io/qstorageinfo_win.cpp b/src/corelib/io/qstorageinfo_win.cpp index aa970778e6..b0d3e7c6da 100644 --- a/src/corelib/io/qstorageinfo_win.cpp +++ b/src/corelib/io/qstorageinfo_win.cpp @@ -61,7 +61,7 @@ void QStorageInfoPrivate::initRootPath() QString path = QDir::toNativeSeparators(rootPath); rootPath.clear(); - if (path.startsWith(QStringLiteral("\\\\?\\"))) + if (path.startsWith(QLatin1String("\\\\?\\"))) path.remove(0, 4); if (path.length() < 2 || path.at(1) != QLatin1Char(':')) return; |