qmake: slightly optimize processPrlFile() calls

add a parameter that indicates whether the passed filename can be only
the basename of a prl file. if so, we can skip the other attempts at
interpreting the file name. that's not only faster, but also clearer.

Change-Id: I6f6da3f4485216021282a08acaefb53e60e7242a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Oswald Buddenhagen 2018-07-09 20:02:27 +02:00
parent caaceb30e6
commit 93362e2607
4 changed files with 13 additions and 13 deletions

View File

@ -876,19 +876,19 @@ MakefileGenerator::init()
}
bool
MakefileGenerator::processPrlFile(QString &file)
MakefileGenerator::processPrlFile(QString &file, bool baseOnly)
{
bool try_replace_file = false;
QString f = fileFixify(file, FileFixifyBackwards);
QString meta_file;
if (f.endsWith(Option::prl_ext)) {
if (!baseOnly && f.endsWith(Option::prl_ext)) {
meta_file = QMakeMetaInfo::checkLib(f);
try_replace_file = true;
} else {
meta_file = QMakeMetaInfo::checkLib(f + Option::prl_ext);
if (!meta_file.isEmpty()) {
try_replace_file = true;
} else {
} else if (!baseOnly) {
int ext = f.lastIndexOf('.');
if (ext != -1)
meta_file = QMakeMetaInfo::checkLib(f.left(ext) + Option::prl_ext);

View File

@ -198,7 +198,7 @@ protected:
//for prl
QString prlFileName(bool fixify=true);
void writePrlFile();
bool processPrlFile(QString &);
bool processPrlFile(QString &, bool baseOnly);
virtual void writePrlFile(QTextStream &);
//make sure libraries are found

View File

@ -443,7 +443,7 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
dep_it != libdirs.end(); ++dep_it) {
QString libBase = (*dep_it).local() + '/'
+ project->first("QMAKE_PREFIX_SHLIB") + lib;
if (linkPrl && processPrlFile(libBase))
if (linkPrl && processPrlFile(libBase, true))
goto found;
for (ProStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
if (exists(libBase + '.' + (*extit)))
@ -471,12 +471,12 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
}
for (const QMakeLocalFileName &dir : qAsConst(frameworkdirs)) {
QString frameworkDirectory = dir.local() + "/" + frameworkName + + ".framework/";
QString suffixedPrl = frameworkDirectory + opt + Option::prl_ext;
if (processPrlFile(suffixedPrl))
QString suffixedPrl = frameworkDirectory + opt;
if (processPrlFile(suffixedPrl, true))
break;
if (hasSuffix) {
QString unsuffixedPrl = frameworkDirectory + frameworkName + Option::prl_ext;
if (processPrlFile(unsuffixedPrl))
QString unsuffixedPrl = frameworkDirectory + frameworkName;
if (processPrlFile(unsuffixedPrl, true))
break;
}
}
@ -487,7 +487,7 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
}
}
} else if (linkPrl) {
processPrlFile(opt);
processPrlFile(opt, false);
}
ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");

View File

@ -106,7 +106,7 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin();
dir_it != dirs.end(); ++dir_it) {
QString cand = (*dir_it).real() + Option::dir_sep + lib;
if (linkPrl && processPrlFile(cand)) {
if (linkPrl && processPrlFile(cand, true)) {
(*it) = cand;
goto found;
}
@ -124,13 +124,13 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
} else if (linkPrl && type == LibFlagFile) {
QString lib = opt.toQString();
if (fileInfo(lib).isAbsolute()) {
if (processPrlFile(lib))
if (processPrlFile(lib, false))
(*it) = lib;
} else {
for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin();
dir_it != dirs.end(); ++dir_it) {
QString cand = (*dir_it).real() + Option::dir_sep + lib;
if (processPrlFile(cand)) {
if (processPrlFile(cand, false)) {
(*it) = cand;
break;
}