Bug 323517 - KFileItemModel wastes memory by needlessly storing default values in a QHash for every item
Summary: KFileItemModel wastes memory by needlessly storing default values in a QHash ...
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: view-engine: general (show other bugs)
Version: 4.11.0
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-14 21:57 UTC by Frank Reininghaus
Modified: 2013-08-14 22:01 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 4.11.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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