Commit 3b16167f authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

pk: cache appstream component names

Extensions would trigger look-ups in appstream that are really slow.
parent 7c483074
......@@ -44,19 +44,20 @@ AppPackageKitResource::AppPackageKitResource(const AppStream::Component& data, c
QString AppPackageKitResource::name() const
{
QString ret;
if (!m_appdata.extends().isEmpty()) {
auto components = backend()->componentsById(m_appdata.extends().constFirst());
if (components.isEmpty())
qWarning() << "couldn't find" << m_appdata.extends() << "which is supposedly extended by" << m_appdata.id();
else
ret = components.constFirst().name() + QLatin1String(" - ") + m_appdata.name();
}
if (m_name.isEmpty()) {
if (!m_appdata.extends().isEmpty()) {
const auto components = backend()->componentsById(m_appdata.extends().constFirst());
if (components.isEmpty())
qWarning() << "couldn't find" << m_appdata.extends() << "which is supposedly extended by" << m_appdata.id();
else
m_name = components.constFirst().name() + QLatin1String(" - ") + m_appdata.name();
}
if (ret.isEmpty())
ret = m_appdata.name();
return ret;
if (m_name.isEmpty())
m_name = m_appdata.name();
}
return m_name;
}
QString AppPackageKitResource::longDescription()
......
......@@ -58,6 +58,7 @@ class AppPackageKitResource : public PackageKitResource
private:
const AppStream::Component m_appdata;
mutable QString m_name;
};
#endif // APPPACKAGEKITRESOURCE_H
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