introduce VCFilter::findFile

Move common code into a function
and exit early from simple search loop.

Change-Id: I88d1227653e28badc213fbe4ebe1e2a19f6e5793
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
Joerg Bornemann 2014-09-23 18:44:02 +02:00
parent a8aad121a2
commit 55027c23df
3 changed files with 18 additions and 16 deletions

View File

@ -1872,14 +1872,8 @@ bool VCXProjectWriter::outputFileConfig(VCFilter filter, XmlOutput &xml, XmlOutp
filter.CompilerTool = VCCLCompilerTool();
filter.CompilerTool.config = filter.Config;
bool inBuild = false;
VCFilterFile info;
for (int i = 0; i < filter.Files.count(); ++i) {
if (filter.Files.at(i).file == filename) {
info = filter.Files.at(i);
inBuild = true;
}
}
bool inBuild;
VCFilterFile info = filter.findFile(filename, &inBuild);
inBuild &= !info.excludeFromBuild;
if (inBuild) {

View File

@ -2241,6 +2241,19 @@ void VCFilter::modifyPCHstage(QString str)
CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)");
}
VCFilterFile VCFilter::findFile(const QString &filePath, bool *found) const
{
for (int i = 0; i < Files.count(); ++i) {
const VCFilterFile &f = Files.at(i);
if (f.file == filePath) {
*found = true;
return f;
}
}
*found = false;
return VCFilterFile();
}
bool VCFilter::addExtraCompiler(const VCFilterFile &info)
{
const QStringList &extraCompilers = Project->extraCompilerSources.value(info.file);
@ -2974,14 +2987,8 @@ void VCProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, const Q
filter.CompilerTool.WarningLevel = warningLevelUnknown;
filter.CompilerTool.config = filter.Config;
bool inBuild = false;
VCFilterFile info;
for (int i = 0; i < filter.Files.count(); ++i) {
if (filter.Files.at(i).file == filename) {
info = filter.Files.at(i);
inBuild = true;
}
}
bool inBuild;
VCFilterFile info = filter.findFile(filename, &inBuild);
inBuild &= !info.excludeFromBuild;
if (inBuild) {

View File

@ -952,6 +952,7 @@ public:
void addFiles(const ProStringList& fileList);
bool addExtraCompiler(const VCFilterFile &info);
void modifyPCHstage(QString str);
VCFilterFile findFile(const QString &filePath, bool *found) const;
// Variables
QString Name;