diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2009-11-25 15:12:43 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-11-25 15:17:32 (GMT) |
commit | cdc0b5fdf1197b07ad446cab339010e8c0fb8e8b (patch) | |
tree | e08492d27bbfae9cb2efe0175d23007d64b49f68 | |
parent | 0fbf2304625cfe895f232b4c64a95bcf0584bd92 (diff) | |
download | Qt-cdc0b5fdf1197b07ad446cab339010e8c0fb8e8b.zip Qt-cdc0b5fdf1197b07ad446cab339010e8c0fb8e8b.tar.gz Qt-cdc0b5fdf1197b07ad446cab339010e8c0fb8e8b.tar.bz2 |
Optimize QFSFileEnginePrivate::canonicalized() by using realpath()
In our benchmark, this makes QFileInfo.canonical*Path() up
to 50% faster. This should also improve application startup time.
Let's see if it works on all Unices and Symbian.
Reviewed-by: mariusSO
-rw-r--r-- | src/corelib/io/qfsfileengine.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 3cf9b7e..6aace2c 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -55,6 +55,7 @@ #include "private/qcore_unix_p.h" #endif #include <stdio.h> +#include <stdlib.h> QT_BEGIN_NAMESPACE @@ -137,6 +138,17 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) if (path.isEmpty()) return path; +#if defined(Q_OS_UNIX) || defined(Q_OS_SYMBIAN) + // FIXME let's see if this stuff works, then we might be able to remove some of the other code + const char *fileName = path.toLocal8Bit().constData(); + char *ret = realpath(fileName, (char*)0); + if (ret) { + QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret)); + free(ret); + return canonicalPath; + } +#endif + QFileInfo fi; const QChar slash(QLatin1Char('/')); QString tmpPath = path; |