mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Do not store default values in QHash<QByteArray, QVariant>
Storing values which are equivalent to default-constructed QVariants does not make much sense because QHash::value returns the same value even if the corresponding key is not found in the hash. This commit reduces Dolphin's memory consumption in large folders by up to 7.3% (tested a folder with 100,000 files in Details View) and reduces the time required for loading a folder. BUG: 323517 FIXED-IN: 4.11.1 REVIEW: 111922
This commit is contained in:
parent
fd5ba3b4b2
commit
59723fca41
|
@ -1275,25 +1275,20 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
|
|||
data.insert(sharedValue("url"), item.url());
|
||||
|
||||
const bool isDir = item.isDir();
|
||||
if (m_requestRole[IsDirRole]) {
|
||||
data.insert(sharedValue("isDir"), isDir);
|
||||
if (m_requestRole[IsDirRole] && isDir) {
|
||||
data.insert(sharedValue("isDir"), true);
|
||||
}
|
||||
|
||||
if (m_requestRole[IsLinkRole]) {
|
||||
const bool isLink = item.isLink();
|
||||
data.insert(sharedValue("isLink"), isLink);
|
||||
if (m_requestRole[IsLinkRole] && item.isLink()) {
|
||||
data.insert(sharedValue("isLink"), true);
|
||||
}
|
||||
|
||||
if (m_requestRole[NameRole]) {
|
||||
data.insert(sharedValue("text"), item.text());
|
||||
}
|
||||
|
||||
if (m_requestRole[SizeRole]) {
|
||||
if (isDir) {
|
||||
data.insert(sharedValue("size"), QVariant());
|
||||
} else {
|
||||
data.insert(sharedValue("size"), item.size());
|
||||
}
|
||||
if (m_requestRole[SizeRole] && !isDir) {
|
||||
data.insert(sharedValue("size"), item.size());
|
||||
}
|
||||
|
||||
if (m_requestRole[DateRole]) {
|
||||
|
@ -1347,17 +1342,15 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
|
|||
data.insert(sharedValue("path"), path);
|
||||
}
|
||||
|
||||
if (m_requestRole[IsExpandableRole]) {
|
||||
data.insert(sharedValue("isExpandable"), item.isDir());
|
||||
if (m_requestRole[IsExpandableRole] && isDir) {
|
||||
data.insert(sharedValue("isExpandable"), true);
|
||||
}
|
||||
|
||||
if (m_requestRole[ExpandedParentsCountRole]) {
|
||||
int level = 0;
|
||||
if (parent) {
|
||||
level = parent->values["expandedParentsCount"].toInt() + 1;
|
||||
const int level = parent->values["expandedParentsCount"].toInt() + 1;
|
||||
data.insert(sharedValue("expandedParentsCount"), level);
|
||||
}
|
||||
|
||||
data.insert(sharedValue("expandedParentsCount"), level);
|
||||
}
|
||||
|
||||
if (item.isMimeTypeKnown()) {
|
||||
|
|
|
@ -791,7 +791,6 @@ void KStandardItemListWidget::updateExpansionArea()
|
|||
{
|
||||
if (m_supportsItemExpanding) {
|
||||
const QHash<QByteArray, QVariant> values = data();
|
||||
Q_ASSERT(values.contains("expandedParentsCount"));
|
||||
const int expandedParentsCount = values.value("expandedParentsCount", 0).toInt();
|
||||
if (expandedParentsCount >= 0) {
|
||||
const qreal widgetHeight = size().height();
|
||||
|
|
Loading…
Reference in a new issue