Bug 323517

Summary: KFileItemModel wastes memory by needlessly storing default values in a QHash for every item
Product: [Applications] dolphin Reporter: Frank Reininghaus <frank78ac>
Component: view-engine: generalAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 4.11.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In: 4.11.1

Description Frank Reininghaus 2013-08-14 21:57:39 UTC
KFileItemModel::retrieveData() stores information about each item in a QHash<QByteArray, QVariant>. This is not necessary, however, if the information is equivalent to a default-constructed QVariant() (e.g., false for a bool or 0 for an int) because QHash::value() would return the very same value even if the information was not stored in the hash at all.

This not only wastes memory, but can, at least in large folders, cause an unnecessary delay when loading the folder because storing all this information in the hash requires time.

This problem is resolved by https://git.reviewboard.kde.org/r/111922/.

Reproducible: Always
Comment 1 Frank Reininghaus 2013-08-14 22:01:23 UTC
Git commit 938f773f1409ff037b718eadf427d7af25b915e0 by Frank Reininghaus.
Committed on 14/08/2013 at 21:57.
Pushed by freininghaus into branch 'KDE/4.11'.

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.
FIXED-IN: 4.11.1
REVIEW: 111922

M  +10   -17   dolphin/src/kitemviews/kfileitemmodel.cpp
M  +0    -1    dolphin/src/kitemviews/kstandarditemlistwidget.cpp

http://commits.kde.org/kde-baseapps/938f773f1409ff037b718eadf427d7af25b915e0