kio: KFileItem::mimeComment() optimization

KFileItem::mimeTypePtr() is lesser version of
KFileItem::determineMimeType() and if KFileItem::determineMimeType() did
not return valid KMimeType::Ptr then neither will KFileItem::mimeTypePtr()
but calling KFileItem::::mimeTypePtr() after KFileItem::determineMimeType()
is redundant

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-07-20 23:57:46 +03:00
parent 632f5e52de
commit ea56b1c92f

View file

@ -712,12 +712,11 @@ QString KFileItem::mimeComment() const
if (!displayType.isEmpty())
return displayType;
KMimeType::Ptr mType = determineMimeType();
KMimeType::Ptr mime = determineMimeType();
bool isLocalUrl = false;
KUrl url = mostLocalUrl(isLocalUrl);
KMimeType::Ptr mime = mimeTypePtr();
// This cannot move to kio_file (with UDS_DISPLAY_TYPE) because it needs
// the mimetype to be determined, which is done here, and possibly delayed...
if (isLocalUrl && !d->isSlow() && mime->is("application/x-desktop")) {
@ -727,12 +726,11 @@ QString KFileItem::mimeComment() const
return comment;
}
QString comment = d->isSlow() ? mType->comment() : mType->comment(url);
QString comment = d->isSlow() ? mime->comment() : mime->comment(url);
//kDebug() << "finding comment for " << url.url() << " : " << d->m_pMimeType->name();
if (!comment.isEmpty())
return comment;
else
return mType->name();
return mime->name();
}
static QString iconFromDesktopFile(const QString& path)