Cleanup & optimize services runner
By reusing the QList of KService::Ptr we get significantly better performance.
I used the following simple testcase for a real-world usage:
void benchmark()
{
QBENCHMARK {
ServiceRunner runner(this, KPluginMetaData(), QVariantList());
runner.prepare();
for (int i = 0; i < 5; ++i) {
Plasma::RunnerContext context;
context.setQuery(QStringLiteral("firefox").left(i + 1)); // virt-manager.desktop
runner.match(context);
}
runner.teardown();
}
}
Before, the test used ~150ms for each iteration. With this change it is down to ~76ms. We do not block the main ui, because this is done in a separate thread, but this is still a significant performance improvement. Especially considering that this runner is pretty much always used by the other KDE launchers and even Plasma Mobile.
A further optimization would be to initialize the data once for each match session and reuse if for consequent queries. However, benchmarks indicated relatively little gain and it would add extra complexity.
Edited by Alexander Lohnau