summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@viroteck.net>2014-12-08 03:00:04 -0800
committerRobin Burchell <robin.burchell@viroteck.net>2014-12-10 14:08:44 +0100
commit99e69dce78cee45fe1ff4ae9976f037e06424e32 (patch)
treee6e0b80f5cf860fc5ca1bd7c3a3bbcc1137e7dbd /src/corelib
parent015002fec9abff6a4c1bb3fa4b9de87279a079c3 (diff)
QFileSystemEngineUnix: Don't stat before retrieving working path.
This is entirely unnecessary. If the path is bad, then getcwd and friends will fail. Doing an extra stat imposes an extra performance overhead without reason. Trivia: A dive into Qt's history shows that the stat dates back to: Sat Aug 12 14:24:36 1995 +0100 The original purpose of the stat was to avoid calling getcwd unless the path had actually changed. Subsequently, the caching was removed, but the stat remained. Change-Id: Ia4598dc74ded36516b3e10e7ab0eb5a6a5690466 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index cd42aff35c..11d421591a 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -723,36 +723,29 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &path)
QFileSystemEntry QFileSystemEngine::currentPath()
{
QFileSystemEntry result;
- QT_STATBUF st;
- if (QT_STAT(".", &st) == 0) {
#if defined(__GLIBC__) && !defined(PATH_MAX)
- char *currentName = ::get_current_dir_name();
- if (currentName) {
- result = QFileSystemEntry(QByteArray(currentName), QFileSystemEntry::FromNativePath());
- ::free(currentName);
- }
+ char *currentName = ::get_current_dir_name();
+ if (currentName) {
+ result = QFileSystemEntry(QByteArray(currentName), QFileSystemEntry::FromNativePath());
+ ::free(currentName);
+ }
#else
- char currentName[PATH_MAX+1];
- if (::getcwd(currentName, PATH_MAX)) {
+ char currentName[PATH_MAX+1];
+ if (::getcwd(currentName, PATH_MAX)) {
#if defined(Q_OS_VXWORKS) && defined(VXWORKS_VXSIM)
- QByteArray dir(currentName);
- if (dir.indexOf(':') < dir.indexOf('/'))
- dir.remove(0, dir.indexOf(':')+1);
+ QByteArray dir(currentName);
+ if (dir.indexOf(':') < dir.indexOf('/'))
+ dir.remove(0, dir.indexOf(':')+1);
- qstrncpy(currentName, dir.constData(), PATH_MAX);
+ qstrncpy(currentName, dir.constData(), PATH_MAX);
#endif
- result = QFileSystemEntry(QByteArray(currentName), QFileSystemEntry::FromNativePath());
- }
+ result = QFileSystemEntry(QByteArray(currentName), QFileSystemEntry::FromNativePath());
+ }
# if defined(QT_DEBUG)
- if (result.isEmpty())
- qWarning("QFileSystemEngine::currentPath: getcwd() failed");
+ if (result.isEmpty())
+ qWarning("QFileSystemEngine::currentPath: getcwd() failed");
# endif
#endif
- } else {
-# if defined(QT_DEBUG)
- qWarning("QFileSystemEngine::currentPath: stat(\".\") failed");
-# endif
- }
return result;
}
QT_END_NAMESPACE