summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@trolltech.com>2009-04-23 17:06:45 +0200
committerJoerg Bornemann <joerg.bornemann@trolltech.com>2009-04-28 12:51:49 +0200
commitd851374c7894ac62367d885e7c24650d8635d2e8 (patch)
tree00b7c72338da819435264beb220bfb1ebb21b5f0 /src/corelib
parentc1691ab1f69919c51f8c66732bbc38bae39329df (diff)
performance improvement of isUncRoot in qfsfileengine_win.cpp
We always called QStringList::split in this function, which was just expensive. Reviewed-by: mauricek
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 522be20792..63506c2c14 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -346,8 +346,15 @@ bool QFSFileEnginePrivate::uncListSharesOnServer(const QString &server, QStringL
static bool isUncRoot(const QString &server)
{
QString localPath = QDir::toNativeSeparators(server);
- QStringList parts = localPath.split(QLatin1Char('\\'), QString::SkipEmptyParts);
- return localPath.startsWith(QLatin1String("\\\\")) && parts.count() <= 1;
+ if (!localPath.startsWith(QLatin1String("\\\\")))
+ return false;
+
+ int idx = localPath.indexOf(QLatin1Char('\\'), 2);
+ if (idx == -1 || idx + 1 == localPath.length())
+ return true;
+
+ localPath = localPath.right(localPath.length() - idx - 1).trimmed();
+ return localPath.isEmpty();
}
static bool isUncPath(const QString &path)