Commit d1462745 authored by David Redondo's avatar David Redondo 🏎

Use Instantiator to create drawer actions to improve startup time

Found with qml profiler that the creation of the drawer actions took the most
time. Using an Instantiator is faster and causes the binding to be evaluated
less often. Before the binding inside Kirigami was evaluated 28 times and it was
the thing the most time was spend on, afterwards creating the window is the most
costly operation.
CCBUG:429855
parent 4a2c70db
......@@ -165,9 +165,6 @@ public:
categories.remove({});
m_categories = categories.values();
m_categories.sort();
m_categories.prepend({});
m_categories.prepend(QStringLiteral(":find:"));
m_categories.prepend(QStringLiteral(":recent:"));
}
Q_SCRIPTABLE QString findFirstEmojiForCategory(const QString &category) {
......
......@@ -96,23 +96,17 @@ Kirigami.ApplicationWindow
collapsed: true
modal: false
function createCategoryActions(categories) {
var actions = []
for(var i in categories) {
var cat = categories[i]
actions.push(cat === ":recent:" ? recentAction :
cat === ":find:" ? searchAction :
cat.length === 0 ? allAction
: categoryActionComponent.createObject(drawer, { category: cat }))
Instantiator {
model: emoji.categories
CategoryAction {
category: modelData
}
onObjectAdded: {
var actions = Array.prototype.map.call(drawer.actions, i => i)
actions.splice(index + 3, 0, object)
drawer.actions = actions
}
return actions;
}
actions: createCategoryActions(emoji.categories)
Component {
id: categoryActionComponent
CategoryAction {}
}
actions: [allAction, searchAction, recentAction]
}
}
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