make ProFileOption persist during the scan of an entire project

there is no point in throwing away and re-recreating invariant data over
and over ...

shaves off ~15% of the load time of Qt 4.6.
This commit is contained in:
Oswald Buddenhagen
2009-12-07 20:49:39 +01:00
parent 0682dae77c
commit ef660880ad
11 changed files with 67 additions and 62 deletions

View File

@@ -35,7 +35,7 @@
using namespace Qt4ProjectManager; using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal; using namespace Qt4ProjectManager::Internal;
ProFileReader::ProFileReader() : ProFileEvaluator(&m_option) ProFileReader::ProFileReader(ProFileOption *option) : ProFileEvaluator(option)
{ {
} }
@@ -45,14 +45,6 @@ ProFileReader::~ProFileReader()
delete pf; delete pf;
} }
void ProFileReader::setQtVersion(const QtVersion *qtVersion)
{
if (qtVersion)
m_option.properties = qtVersion->versionInfo();
else
m_option.properties.clear();
}
bool ProFileReader::readProFile(const QString &fileName) bool ProFileReader::readProFile(const QString &fileName)
{ {
//disable caching -> list of include files is not updated otherwise //disable caching -> list of include files is not updated otherwise

View File

@@ -31,7 +31,6 @@
#define PROFILEREADER_H #define PROFILEREADER_H
#include "profileevaluator.h" #include "profileevaluator.h"
#include "qtversionmanager.h"
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QMap> #include <QtCore/QMap>
@@ -44,10 +43,9 @@ class ProFileReader : public QObject, public ProFileEvaluator
Q_OBJECT Q_OBJECT
public: public:
ProFileReader(); ProFileReader(ProFileOption *option);
~ProFileReader(); ~ProFileReader();
void setQtVersion(const QtVersion *qtVersion);
bool readProFile(const QString &fileName); bool readProFile(const QString &fileName);
QList<ProFile*> includeFiles() const; QList<ProFile*> includeFiles() const;
@@ -67,7 +65,6 @@ private:
private: private:
QMap<QString, ProFile *> m_includeFiles; QMap<QString, ProFile *> m_includeFiles;
QList<ProFile *> m_proFiles; QList<ProFile *> m_proFiles;
ProFileOption m_option;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -571,8 +571,7 @@ void MaemoRunConfiguration::updateTarget()
return; return;
} }
QtVersion *qtVersion = qt4bc->qtVersion(); ProFileReader *reader = qt4Project->createProFileReader(proFileNode);
ProFileReader *reader = proFileNode->createProFileReader();
reader->setCumulative(false); reader->setCumulative(false);
// Find out what flags we pass on to qmake // Find out what flags we pass on to qmake
@@ -582,7 +581,7 @@ void MaemoRunConfiguration::updateTarget()
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments); reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
if (!reader->readProFile(m_proFilePath)) { if (!reader->readProFile(m_proFilePath)) {
delete reader; qt4Project->destroyProFileReader(reader);
Core::ICore::instance()->messageManager()->printToOutputPane(tr( Core::ICore::instance()->messageManager()->printToOutputPane(tr(
"Could not parse %1. The Maemo run configuration %2 " "Could not parse %1. The Maemo run configuration %2 "
"can not be started.").arg(m_proFilePath).arg(name())); "can not be started.").arg(m_proFilePath).arg(name()));
@@ -620,7 +619,7 @@ void MaemoRunConfiguration::updateTarget()
target = QFileInfo(m_proFilePath).baseName(); target = QFileInfo(m_proFilePath).baseName();
m_executable = QDir::cleanPath(baseDir + QLatin1Char('/') + target); m_executable = QDir::cleanPath(baseDir + QLatin1Char('/') + target);
delete reader; qt4Project->destroyProFileReader(reader);
} }
emit targetInformationChanged(); emit targetInformationChanged();

View File

@@ -288,8 +288,7 @@ void S60DeviceRunConfiguration::updateTarget()
emit targetInformationChanged(); emit targetInformationChanged();
return; return;
} }
QtVersion *qtVersion = qt4bc->qtVersion(); ProFileReader *reader = qt4Project()->createProFileReader(proFileNode);
ProFileReader *reader = proFileNode->createProFileReader();
reader->setCumulative(false); reader->setCumulative(false);
// Find out what flags we pass on to qmake // Find out what flags we pass on to qmake
@@ -299,7 +298,7 @@ void S60DeviceRunConfiguration::updateTarget()
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments); reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
if (!reader->readProFile(m_proFilePath)) { if (!reader->readProFile(m_proFilePath)) {
delete reader; qt4Project()->destroyProFileReader(reader);
Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The QtS60 Device run configuration %2 can not be started.").arg(m_proFilePath).arg(name())); Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The QtS60 Device run configuration %2 can not be started.").arg(m_proFilePath).arg(name()));
return; return;
} }
@@ -346,7 +345,7 @@ void S60DeviceRunConfiguration::updateTarget()
else else
m_target = QLatin1String("urel"); m_target = QLatin1String("urel");
m_baseFileName += QLatin1Char('_') + m_platform + QLatin1Char('_') + m_target; m_baseFileName += QLatin1Char('_') + m_platform + QLatin1Char('_') + m_target;
delete reader; qt4Project()->destroyProFileReader(reader);
m_cachedTargetInformationValid = true; m_cachedTargetInformationValid = true;
emit targetInformationChanged(); emit targetInformationChanged();
} }

View File

@@ -135,8 +135,7 @@ void S60EmulatorRunConfiguration::updateTarget()
emit targetInformationChanged(); emit targetInformationChanged();
return; return;
} }
QtVersion *qtVersion = qt4bc->qtVersion(); ProFileReader *reader = qt4Project()->createProFileReader(proFileNode);
ProFileReader *reader = proFileNode->createProFileReader();
reader->setCumulative(false); reader->setCumulative(false);
// Find out what flags we pass on to qmake // Find out what flags we pass on to qmake
@@ -146,11 +145,12 @@ void S60EmulatorRunConfiguration::updateTarget()
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments); reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
if (!reader->readProFile(m_proFilePath)) { if (!reader->readProFile(m_proFilePath)) {
delete reader; qt4Project()->destroyProFileReader(reader);
Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The Qt for Symbian emulator run configuration %2 can not be started.").arg(m_proFilePath).arg(name())); Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The Qt for Symbian emulator run configuration %2 can not be started.").arg(m_proFilePath).arg(name()));
return; return;
} }
QtVersion *qtVersion = qt4bc->qtVersion();
QString baseDir = S60Manager::instance()->deviceForQtVersion(qtVersion).epocRoot; QString baseDir = S60Manager::instance()->deviceForQtVersion(qtVersion).epocRoot;
QString qmakeBuildConfig = "urel"; QString qmakeBuildConfig = "urel";
if (qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild) if (qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild)
@@ -165,7 +165,7 @@ void S60EmulatorRunConfiguration::updateTarget()
QDir::cleanPath(baseDir + QLatin1Char('/') + target)); QDir::cleanPath(baseDir + QLatin1Char('/') + target));
m_executable += QLatin1String(".exe"); m_executable += QLatin1String(".exe");
delete reader; qt4Project()->destroyProFileReader(reader);
m_cachedTargetInformationValid = true; m_cachedTargetInformationValid = true;
emit targetInformationChanged(); emit targetInformationChanged();
} }

View File

@@ -560,10 +560,10 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
if (filePaths.isEmpty()) if (filePaths.isEmpty())
return; return;
ProFileReader *reader = m_qt4ProFileNode->createProFileReader(); ProFileReader *reader = m_project->createProFileReader(m_qt4ProFileNode);
if (!reader->readProFile(m_qt4ProFileNode->path())) { if (!reader->readProFile(m_qt4ProFileNode->path())) {
m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath)); m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath));
delete reader; m_project->destroyProFileReader(reader);
return; return;
} }
@@ -576,7 +576,7 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
// Check for modified editors // Check for modified editors
if (!saveModifiedEditors(m_projectFilePath)) { if (!saveModifiedEditors(m_projectFilePath)) {
delete reader; m_project->destroyProFileReader(reader);
return; return;
} }
@@ -661,7 +661,7 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
// save file // save file
save(includeFile); save(includeFile);
delete reader; m_project->destroyProFileReader(reader);
} }
void Qt4PriFileNode::save(ProFile *includeFile) void Qt4PriFileNode::save(ProFile *includeFile)
@@ -805,10 +805,10 @@ void Qt4ProFileNode::scheduleUpdate()
void Qt4ProFileNode::update() void Qt4ProFileNode::update()
{ {
ProFileReader *reader = createProFileReader(); ProFileReader *reader = m_project->createProFileReader(this);
if (!reader->readProFile(m_projectFilePath)) { if (!reader->readProFile(m_projectFilePath)) {
m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath)); m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath));
delete reader; m_project->destroyProFileReader(reader);
invalidate(); invalidate();
return; return;
} }
@@ -952,7 +952,7 @@ void Qt4ProFileNode::update()
if (Qt4NodesWatcher *qt4Watcher = qobject_cast<Qt4NodesWatcher*>(watcher)) if (Qt4NodesWatcher *qt4Watcher = qobject_cast<Qt4NodesWatcher*>(watcher))
emit qt4Watcher->proFileUpdated(this); emit qt4Watcher->proFileUpdated(this);
delete reader; m_project->destroyProFileReader(reader);
} }
namespace { namespace {
@@ -1084,23 +1084,6 @@ QStringList Qt4ProFileNode::updateUiFiles()
return toUpdate; return toUpdate;
} }
ProFileReader *Qt4ProFileNode::createProFileReader() const
{
ProFileReader *reader = new ProFileReader();
connect(reader, SIGNAL(errorFound(QString)),
m_project, SLOT(proFileParseError(QString)));
Qt4BuildConfiguration *qt4bc = m_project->activeQt4BuildConfiguration();
QtVersion *version = qt4bc->qtVersion();
if (version->isValid())
reader->setQtVersion(version);
reader->setOutputDir(buildDir());
return reader;
}
Qt4ProFileNode *Qt4ProFileNode::createSubProFileNode(const QString &path) Qt4ProFileNode *Qt4ProFileNode::createSubProFileNode(const QString &path)
{ {
Qt4ProFileNode *subProFileNode = new Qt4ProFileNode(m_project, path); Qt4ProFileNode *subProFileNode = new Qt4ProFileNode(m_project, path);

View File

@@ -198,9 +198,6 @@ public:
Qt4ProFileNode *findProFileFor(const QString &string); Qt4ProFileNode *findProFileFor(const QString &string);
//internal
ProFileReader *createProFileReader() const;
public slots: public slots:
void scheduleUpdate(); void scheduleUpdate();
void update(); void update();

View File

@@ -320,7 +320,8 @@ Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) :
m_fileInfo(new Qt4ProjectFile(this, fileName, this)), m_fileInfo(new Qt4ProjectFile(this, fileName, this)),
m_isApplication(true), m_isApplication(true),
m_projectFiles(new Qt4ProjectFiles), m_projectFiles(new Qt4ProjectFiles),
m_lastActiveQt4BuildConfiguration(0) m_lastActiveQt4BuildConfiguration(0),
m_proFileOption(0)
{ {
m_manager->registerProject(this); m_manager->registerProject(this);
@@ -855,6 +856,38 @@ void Qt4Project::proFileParseError(const QString &errorMessage)
Core::ICore::instance()->messageManager()->printToOutputPane(errorMessage); Core::ICore::instance()->messageManager()->printToOutputPane(errorMessage);
} }
ProFileReader *Qt4Project::createProFileReader(Qt4ProFileNode *qt4ProFileNode)
{
if (!m_proFileOption) {
m_proFileOption = new ProFileOption;
m_proFileOptionRefCnt = 0;
if (Qt4BuildConfiguration *qt4bc = activeQt4BuildConfiguration()) {
QtVersion *version = qt4bc->qtVersion();
if (version->isValid())
m_proFileOption->properties = version->versionInfo();
}
}
++m_proFileOptionRefCnt;
ProFileReader *reader = new ProFileReader(m_proFileOption);
connect(reader, SIGNAL(errorFound(QString)),
this, SLOT(proFileParseError(QString)));
reader->setOutputDir(qt4ProFileNode->buildDir());
return reader;
}
void Qt4Project::destroyProFileReader(ProFileReader *reader)
{
delete reader;
if (!--m_proFileOptionRefCnt) {
delete m_proFileOption;
m_proFileOption = 0;
}
}
Qt4ProFileNode *Qt4Project::rootProjectNode() const Qt4ProFileNode *Qt4Project::rootProjectNode() const
{ {
return m_rootProjectNode; return m_rootProjectNode;

View File

@@ -59,7 +59,7 @@ namespace CppTools {
} }
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class ProFile; class ProFileOption;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
@@ -95,9 +95,6 @@ class Qt4ProjectFile : public Core::IFile
{ {
Q_OBJECT Q_OBJECT
// needed for createProFileReader
friend class Internal::Qt4RunConfiguration;
public: public:
Qt4ProjectFile(Qt4Project *project, const QString &filePath, QObject *parent = 0); Qt4ProjectFile(Qt4Project *project, const QString &filePath, QObject *parent = 0);
@@ -196,6 +193,9 @@ public:
virtual QStringList includePaths(const QString &fileName) const; virtual QStringList includePaths(const QString &fileName) const;
virtual QStringList frameworkPaths(const QString &fileName) const; virtual QStringList frameworkPaths(const QString &fileName) const;
Internal::ProFileReader *createProFileReader(Internal::Qt4ProFileNode *qt4ProFileNode);
void destroyProFileReader(Internal::ProFileReader *reader);
signals: signals:
/// convenience signal, emitted if either the active buildconfiguration emits /// convenience signal, emitted if either the active buildconfiguration emits
/// targetInformationChanged() or if the active build configuration changes /// targetInformationChanged() or if the active build configuration changes
@@ -262,6 +262,10 @@ private:
friend class Qt4ProjectFile; friend class Qt4ProjectFile;
friend class Internal::Qt4ProjectConfigWidget; friend class Internal::Qt4ProjectConfigWidget;
// cached data during project rescan
ProFileOption *m_proFileOption;
int m_proFileOptionRefCnt;
}; };
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager

View File

@@ -572,7 +572,7 @@ void Qt4RunConfiguration::updateTarget()
emit effectiveTargetInformationChanged(); emit effectiveTargetInformationChanged();
return; return;
} }
ProFileReader *reader = proFileNode->createProFileReader(); ProFileReader *reader = qt4Project()->createProFileReader(proFileNode);
reader->setCumulative(false); reader->setCumulative(false);
// Find out what flags we pass on to qmake // Find out what flags we pass on to qmake
@@ -582,7 +582,7 @@ void Qt4RunConfiguration::updateTarget()
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments); reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
if (!reader->readProFile(m_proFilePath)) { if (!reader->readProFile(m_proFilePath)) {
delete reader; qt4Project()->destroyProFileReader(reader);
Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The Qt4 run configuration %2 can not be started.").arg(m_proFilePath).arg(name())); Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The Qt4 run configuration %2 can not be started.").arg(m_proFilePath).arg(name()));
return; return;
} }
@@ -636,7 +636,7 @@ void Qt4RunConfiguration::updateTarget()
m_executable += QLatin1String(".exe"); m_executable += QLatin1String(".exe");
#endif #endif
delete reader; qt4Project()->destroyProFileReader(reader);
m_cachedTargetInformationValid = true; m_cachedTargetInformationValid = true;

View File

@@ -1205,8 +1205,9 @@ void QtVersion::updateToolChainAndMkspec() const
// qDebug()<<"mkspec for "<<qmakeCommand()<<" is "<<m_mkspec<<m_mkspecFullPath; // qDebug()<<"mkspec for "<<qmakeCommand()<<" is "<<m_mkspec<<m_mkspecFullPath;
ProFileReader *reader = new ProFileReader(); ProFileOption option;
reader->setQtVersion(this); option.properties = versionInfo();
ProFileReader *reader = new ProFileReader(&option);
reader->setCumulative(false); reader->setCumulative(false);
reader->setParsePreAndPostFiles(false); reader->setParsePreAndPostFiles(false);
reader->readProFile(m_mkspecFullPath + "/qmake.conf"); reader->readProFile(m_mkspecFullPath + "/qmake.conf");