Commit ba9ac17e authored by Milian Wolff's avatar Milian Wolff

Restructure code to minimize temporary allocations.

In EntityMimeTypeFilterModel::filterAcceptsRow, we can check the
mimetype first, before checking whether the item has a payload.
The latter requires a temporary data allocation inside QVariant
for the Akonadi::Item, whereas the former can leverage the optimized
QVariant code for QString, which is faster.

REVIEW: 121407
parent b24fece4
...@@ -109,20 +109,20 @@ bool EntityMimeTypeFilterModel::filterAcceptsRow(int sourceRow, const QModelInde ...@@ -109,20 +109,20 @@ bool EntityMimeTypeFilterModel::filterAcceptsRow(int sourceRow, const QModelInde
Q_D(const EntityMimeTypeFilterModel); Q_D(const EntityMimeTypeFilterModel);
const QModelIndex idx = sourceModel()->index(sourceRow, 0, sourceParent); const QModelIndex idx = sourceModel()->index(sourceRow, 0, sourceParent);
const Akonadi::Item item = idx.data(EntityTreeModel::ItemRole).value<Akonadi::Item>();
if (item.isValid() && !item.hasPayload()) {
kDebug() << "Item " << item.id() << " doesn't have payload";
return false;
}
const QString rowMimetype = idx.data(EntityTreeModel::MimeTypeRole).toString(); const QString rowMimetype = idx.data(EntityTreeModel::MimeTypeRole).toString();
if (d->excludedMimeTypes.contains(rowMimetype)) { if (d->excludedMimeTypes.contains(rowMimetype)) {
return false; return false;
} }
if (d->includedMimeTypes.isEmpty() ||
d->includedMimeTypes.contains(rowMimetype)) { if (d->includedMimeTypes.isEmpty() || d->includedMimeTypes.contains(rowMimetype)) {
const Akonadi::Item item = idx.data(EntityTreeModel::ItemRole).value<Akonadi::Item>();
if (item.isValid() && !item.hasPayload()) {
kDebug() << "Item " << item.id() << " doesn't have payload";
return false;
}
return true; return true;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment