QIcon::addFile: don't use QMimeDatabase for every PNG being loaded
Commit 710ff392d9 introduced this fallback code for the case where the
extension was empty. Let's make it happen only in that case, so that the
much more common case of "foo.png" doesn't go through
iconEngineFromSuffix twice, nor through QMimeDatabase (which has to load
and parse an XML file in order to determine preferredSuffix(),
unfortunately).
Found using heaptrack.
Change-Id: Iab6b71e1fa23916029c9e2ba25447a12d70f88a5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
parent
4f4a33196d
commit
80cc6bcec4
|
|
@ -1078,11 +1078,12 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
|
|||
if (!d) {
|
||||
|
||||
QFileInfo info(fileName);
|
||||
QIconEngine *engine = iconEngineFromSuffix(fileName, info.suffix());
|
||||
QString suffix = info.suffix();
|
||||
#ifndef QT_NO_MIMETYPE
|
||||
if (!engine)
|
||||
engine = iconEngineFromSuffix(fileName, QMimeDatabase().mimeTypeForFile(info).preferredSuffix());
|
||||
if (suffix.isEmpty())
|
||||
suffix = QMimeDatabase().mimeTypeForFile(info).preferredSuffix(); // determination from contents
|
||||
#endif // !QT_NO_MIMETYPE
|
||||
QIconEngine *engine = iconEngineFromSuffix(fileName, suffix);
|
||||
d = new QIconPrivate(engine ? engine : new QPixmapIconEngine);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue