summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorck <qt-info@nokia.com>2009-12-14 15:51:39 (GMT)
committerck <qt-info@nokia.com>2009-12-14 15:51:39 (GMT)
commitbff37a821728615d5b1c766d1fbcb80bdccfb9fd (patch)
tree04c0f72b1cb6bda045f83636e8927d536e884f57 /tools
parent454e87a57b6876b8db2180236082d7c7bc408a0e (diff)
downloadQt-bff37a821728615d5b1c766d1fbcb80bdccfb9fd.zip
Qt-bff37a821728615d5b1c766d1fbcb80bdccfb9fd.tar.gz
Qt-bff37a821728615d5b1c766d1fbcb80bdccfb9fd.tar.bz2
Assistant: Performance improvements in qhelpgenerator.
- Get rid of double container lookups for conditional access. - count() == 0 => isEmpty(). Reviewed-by: kh1
Diffstat (limited to 'tools')
-rw-r--r--tools/assistant/lib/qhelpgenerator.cpp27
-rw-r--r--tools/assistant/lib/qhelpgenerator_p.h2
2 files changed, 16 insertions, 13 deletions
diff --git a/tools/assistant/lib/qhelpgenerator.cpp b/tools/assistant/lib/qhelpgenerator.cpp
index 1bb4cc8..8f1b780 100644
--- a/tools/assistant/lib/qhelpgenerator.cpp
+++ b/tools/assistant/lib/qhelpgenerator.cpp
@@ -538,7 +538,8 @@ bool QHelpGenerator::insertFiles(const QStringList &files, const QString &rootPa
}
int fileId = -1;
- if (!d->fileMap.contains(fileName)) {
+ QMap<QString, int>::Iterator fileMapIt = d->fileMap.find(fileName);
+ if (fileMapIt == d->fileMap.end()) {
fileDataList.append(qCompress(data));
fileNameData.name = fileName;
@@ -552,18 +553,20 @@ bool QHelpGenerator::insertFiles(const QStringList &files, const QString &rootPa
++tableFileId;
} else {
- fileId = d->fileMap.value(fileName);
+ fileId = fileMapIt.value();
+ QSet<int> &fileFilterSet = d->fileFilterMap[fileId];
+ QSet<int> &tmpFileFilterSet = tmpFileFilterMap[fileId];
foreach (const int &filter, filterAtts) {
- if (!d->fileFilterMap.value(fileId).contains(filter)
- && !tmpFileFilterMap.value(fileId).contains(filter)) {
- d->fileFilterMap[fileId].insert(filter);
- tmpFileFilterMap[fileId].insert(filter);
+ if (!fileFilterSet.contains(filter)
+ && !tmpFileFilterSet.contains(filter)) {
+ fileFilterSet.insert(filter);
+ tmpFileFilterSet.insert(filter);
}
}
}
}
- if (tmpFileFilterMap.count()) {
+ if (!tmpFileFilterMap.isEmpty()) {
d->query->exec(QLatin1String("BEGIN"));
QMap<int, QSet<int> >::const_iterator it = tmpFileFilterMap.constBegin();
while (it != tmpFileFilterMap.constEnd()) {
@@ -626,8 +629,7 @@ bool QHelpGenerator::registerCustomFilter(const QString &filterName,
while (d->query->next()) {
attributeMap.insert(d->query->value(1).toString(),
d->query->value(0).toInt());
- if (idsToInsert.contains(d->query->value(1).toString()))
- idsToInsert.removeAll(d->query->value(1).toString());
+ idsToInsert.removeAll(d->query->value(1).toString());
}
foreach (QString id, idsToInsert) {
@@ -675,7 +677,7 @@ bool QHelpGenerator::registerCustomFilter(const QString &filterName,
return true;
}
-bool QHelpGenerator::insertKeywords(const QList<QHelpDataIndexItem> keywords,
+bool QHelpGenerator::insertKeywords(const QList<QHelpDataIndexItem> &keywords,
const QStringList &filterAttributes)
{
if (!d->query)
@@ -717,8 +719,9 @@ bool QHelpGenerator::insertKeywords(const QList<QHelpDataIndexItem> keywords,
if (fName.startsWith(QLatin1String("./")))
fName = fName.mid(2);
- if (d->fileMap.contains(fName))
- fileId = d->fileMap.value(fName);
+ QMap<QString, int>::ConstIterator it = d->fileMap.find(fName);
+ if (it != d->fileMap.end())
+ fileId = it.value();
else
fileId = 1;
diff --git a/tools/assistant/lib/qhelpgenerator_p.h b/tools/assistant/lib/qhelpgenerator_p.h
index 77189b0..de991e7 100644
--- a/tools/assistant/lib/qhelpgenerator_p.h
+++ b/tools/assistant/lib/qhelpgenerator_p.h
@@ -97,7 +97,7 @@ private:
const QStringList &filterAttribs, bool forceUpdate = false);
bool registerVirtualFolder(const QString &folderName, const QString &ns);
bool insertFilterAttributes(const QStringList &attributes);
- bool insertKeywords(const QList<QHelpDataIndexItem> keywords,
+ bool insertKeywords(const QList<QHelpDataIndexItem> &keywords,
const QStringList &filterAttributes);
bool insertFiles(const QStringList &files, const QString &rootPath,
const QStringList &filterAttributes);