forked from qt-creator/qt-creator
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 <tobias.hunger@qt.io>
This commit is contained in:
@@ -681,7 +681,6 @@ PriFileEvalResult QmakePriFileNode::extractValues(const EvalInput &input,
|
||||
|
||||
const QVector<QmakeNodeStaticData::FileTypeData> &fileTypes = qmakeNodeStaticData()->fileTypeData;
|
||||
// update files
|
||||
QFileInfo tmpFi;
|
||||
for (int i = 0; i < fileTypes.size(); ++i) {
|
||||
FileType type = fileTypes.at(i).type;
|
||||
const QList<VariableAndVPathInformation> &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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user