diff options
author | mread <qt-info@nokia.com> | 2010-02-26 14:34:16 (GMT) |
---|---|---|
committer | mread <qt-info@nokia.com> | 2010-02-26 15:34:24 (GMT) |
commit | 4302c8fa7a234f6f4cfc35f572b93a000d199fe3 (patch) | |
tree | bec678094c45c3fcaff86bdf843075ea8f23b0dc /src | |
parent | 7ca00ed67cb18fb858e1e89cec21b3db696fa923 (diff) | |
download | Qt-4302c8fa7a234f6f4cfc35f572b93a000d199fe3.zip Qt-4302c8fa7a234f6f4cfc35f572b93a000d199fe3.tar.gz Qt-4302c8fa7a234f6f4cfc35f572b93a000d199fe3.tar.bz2 |
Symbian file system use optimisation for stat and symlinks
Symbian implementation of fileFlags calls both doStat and isSymlink
resulting in calls to both stat and lstat. However most of the time,
ie when accessing a normal file rather than a symlink, lstat gives all
the information we require. So this change uses lstat where possible,
and caches its result for both doStat and isSymlink.
During start of DesktopServices app, this cuts calls to stat/lstat by
45%.
Reviewed-by: Shane Kearns
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qfsfileengine_unix.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index d2fa744..1331f54 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -668,6 +668,16 @@ bool QFSFileEnginePrivate::doStat() const could_stat = (QT_FSTAT(QT_FILENO(fh), &st) == 0); } else if (fd == -1) { // ### actually covers two cases: d->fh and when the file is not open +#if defined(Q_OS_SYMBIAN) + // Optimisation for Symbian where fileFlags() calls both doStat() and isSymlink(), but rarely on real links. + // When the filename is not a link, lstat will return the same info as stat, but this also removes + // any need for a further call to lstat to check if the file is a link. + need_lstat = false; + could_stat = (QT_LSTAT(nativeFilePath.constData(), &st) == 0); + is_link = could_stat ? S_ISLNK(st.st_mode) : false; + // if it turns out this was a link, we can call stat too. + if (is_link) +#endif could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0); } else { could_stat = (QT_FSTAT(fd, &st) == 0); |