Don't tear down renderer and other busy work when Svg::setImagePath is invoked with the same arg

Summary:
During my plasmashell startup this saves time for 17 calls. Opening
something like Simple Menu saves another ~dozen.

It's worth investigating why Svg::setImagePath gets called repeatedly
with the same args to begin with, but this is worth doing anyway.

Reviewers: #plasma, davidedmundson, mart

Subscribers: plasma-devel, #frameworks

Tags: #plasma, #frameworks

Differential Revision: https://phabricator.kde.org/D9115
This commit is contained in:
Eike Hein 2017-12-03 03:05:33 +09:00
parent df09180d31
commit 4ce50cc61f
2 changed files with 7 additions and 0 deletions

View File

@ -103,6 +103,7 @@ public:
QHash<QString, QRectF> localRectCache;
QHash<QString, QSize> elementsWithSizeHints;
SharedSvgRenderer::Ptr renderer;
QString requestedPath;
QString themePath;
QString path;
QSizeF size;

View File

@ -182,6 +182,12 @@ QString SvgPrivate::cachePath(const QString &path, const QSize &size) const
bool SvgPrivate::setImagePath(const QString &imagePath)
{
if (requestedPath == imagePath) {
return false;
}
requestedPath = imagePath;
QString actualPath = imagePath;
if (imagePath.startsWith(QLatin1String("file://"))) {
//length of file://