diff options
author | Joerg Bornemann <joerg.bornemann@trolltech.com> | 2009-04-23 15:06:45 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@trolltech.com> | 2009-04-28 10:51:49 (GMT) |
commit | d851374c7894ac62367d885e7c24650d8635d2e8 (patch) | |
tree | 00b7c72338da819435264beb220bfb1ebb21b5f0 /src | |
parent | c1691ab1f69919c51f8c66732bbc38bae39329df (diff) | |
download | Qt-d851374c7894ac62367d885e7c24650d8635d2e8.zip Qt-d851374c7894ac62367d885e7c24650d8635d2e8.tar.gz Qt-d851374c7894ac62367d885e7c24650d8635d2e8.tar.bz2 |
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')
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 522be20..63506c2 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) |