From cf82f210804151452fce3cddb3cb2793dab976eb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 24 Oct 2016 14:58:11 +0200 Subject: [PATCH] shave off duplicate stat()ing of source files ProFileEvaluator::absoluteFileValues() now returns only files, which allows us to skip the subsequent QFileInfo::isFile() calls at some call sites. as a side effect, IoUtils::fileType() does not see anything except regular files and directories any more. that's not expected to be a problem, given the function's scope. Change-Id: I53063ad8cacb3afe5cc1baf6d6d5feba3465e74f Reviewed-by: Tobias Hunger --- src/plugins/qmakeprojectmanager/qmakenodes.cpp | 15 ++++----------- src/shared/proparser/ioutils.cpp | 2 +- src/shared/proparser/profileevaluator.cpp | 1 + src/shared/proparser/qmakevfs.cpp | 2 +- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp index e19e2a7f314..9bb0bcebf3a 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp @@ -681,7 +681,6 @@ PriFileEvalResult QmakePriFileNode::extractValues(const EvalInput &input, const QVector &fileTypes = qmakeNodeStaticData()->fileTypeData; // update files - QFileInfo tmpFi; for (int i = 0; i < fileTypes.size(); ++i) { FileType type = fileTypes.at(i).type; const QList &qmakeVariables = variableAndVPathInformation.at(i); @@ -689,19 +688,13 @@ PriFileEvalResult QmakePriFileNode::extractValues(const EvalInput &input, foreach (const VariableAndVPathInformation &qmakeVariable, qmakeVariables) { foreach (ProFile *includeFileExact, includeFilesExact) { QStringList tmp = input.readerExact->absoluteFileValues(qmakeVariable.variable, input.projectDir, qmakeVariable.vPathsExact, includeFileExact); - foreach (const QString &t, tmp) { - tmpFi.setFile(t); - if (tmpFi.isFile()) - newFilePaths += FileName::fromString(t); - } + foreach (const QString &t, tmp) + newFilePaths += FileName::fromString(t); } foreach (ProFile *includeFileCumlative, includeFilesCumlative) { QStringList tmp = input.readerCumulative->absoluteFileValues(qmakeVariable.variable, input.projectDir, qmakeVariable.vPathsCumulative, includeFileCumlative); - foreach (const QString &t, tmp) { - tmpFi.setFile(t); - if (tmpFi.isFile()) - newFilePaths += FileName::fromString(t); - } + foreach (const QString &t, tmp) + newFilePaths += FileName::fromString(t); } } diff --git a/src/shared/proparser/ioutils.cpp b/src/shared/proparser/ioutils.cpp index 57b2812c8fd..4239d6ba5c9 100644 --- a/src/shared/proparser/ioutils.cpp +++ b/src/shared/proparser/ioutils.cpp @@ -52,7 +52,7 @@ IoUtils::FileType IoUtils::fileType(const QString &fileName) struct ::stat st; if (::stat(fileName.toLocal8Bit().constData(), &st)) return FileNotFound; - return S_ISDIR(st.st_mode) ? FileIsDir : FileIsRegular; + return S_ISDIR(st.st_mode) ? FileIsDir : S_ISREG(st.st_mode) ? FileIsRegular : FileNotFound; #endif } diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 5b937d3f094..1df3dc4b518 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -153,6 +153,7 @@ QStringList ProFileEvaluator::absoluteFileValues( if (wildcard.contains(QLatin1Char('*')) || wildcard.contains(QLatin1Char('?'))) { wildcard.detach(); // Keep m_tmp out of QRegExp's cache QDir theDir(absDir); + theDir.setFilter(theDir.filter() & ~QDir::AllDirs); foreach (const QString &fn, theDir.entryList(QStringList(wildcard))) if (fn != QLatin1String(".") && fn != QLatin1String("..")) result << absDir + QLatin1Char('/') + fn; diff --git a/src/shared/proparser/qmakevfs.cpp b/src/shared/proparser/qmakevfs.cpp index 81759fa8160..a46b211aeff 100644 --- a/src/shared/proparser/qmakevfs.cpp +++ b/src/shared/proparser/qmakevfs.cpp @@ -169,7 +169,7 @@ bool QMakeVfs::exists(const QString &fn) if (it != m_files.constEnd()) return it->constData() != m_magicMissing.constData(); #endif - bool ex = IoUtils::exists(fn); + bool ex = IoUtils::fileType(fn) == IoUtils::FileIsRegular; #ifndef PROEVALUATOR_FULL m_files[fn] = ex ? m_magicExisting : m_magicMissing; #endif