]> cloud.milkyroute.net Git - dolphin.git/commit
Store the selected items in a more efficient way
authorFrank Reininghaus <frank78ac@googlemail.com>
Wed, 30 Oct 2013 22:21:09 +0000 (23:21 +0100)
committerFrank Reininghaus <frank78ac@googlemail.com>
Wed, 30 Oct 2013 22:22:23 +0000 (23:22 +0100)
commitfc2ab478989fb4effc14c06aa56fdb29d3143b35
tree1ab12809d805c06137d34a2b1fe088cdbb8b4edf
parent903381a8982a0aefc7b1eba223f9ee38ded3f018
Store the selected items in a more efficient way

Since Dolphin 2.0, we have stored the selected items in a QSet<int>,
which is neither space-efficient nor particularly fast when inserting
many items which are in a consecutive range.

This commit replaces the QSet<int> by a new class "KItemSet", which
stores the items in a sorted list of ranges. For each range, we only
store the first index and the length of the range, so we need a lot
less memory for most common selection patterns, and we also save quite
a few CPU cycles in many situations, because adding an item to the
KItemSet will in many cases not need a memory allocation at all, and
it's particularly easy when inserting sorted items into the KItemSet in
a row.

KItemSet contains a minimal subset of QSet's API which makes it
suitable as a drop-in replacement for our needs. It also has iterators,
such that the items can be iterated through easily, also with foreach.
One advantage of KItemSet compared to QSet<int> is that the items are
always iterated through in ascending order.

REVIEW: 113488
26 files changed:
src/CMakeLists.txt
src/kitemviews/kfileitemlistview.cpp
src/kitemviews/kfileitemlistview.h
src/kitemviews/kfileitemmodel.cpp
src/kitemviews/kfileitemmodel.h
src/kitemviews/kitemlistcontroller.cpp
src/kitemviews/kitemlistcontroller.h
src/kitemviews/kitemlistselectionmanager.cpp
src/kitemviews/kitemlistselectionmanager.h
src/kitemviews/kitemlistview.cpp
src/kitemviews/kitemlistview.h
src/kitemviews/kitemlistviewaccessible.cpp
src/kitemviews/kitemmodelbase.cpp
src/kitemviews/kitemmodelbase.h
src/kitemviews/kitemset.cpp [new file with mode: 0644]
src/kitemviews/kitemset.h [new file with mode: 0644]
src/kitemviews/kstandarditemmodel.cpp
src/kitemviews/kstandarditemmodel.h
src/panels/places/placesitemmodel.cpp
src/panels/places/placesitemmodel.h
src/tests/CMakeLists.txt
src/tests/kitemlistcontrollertest.cpp
src/tests/kitemlistselectionmanagertest.cpp
src/tests/kitemsettest.cpp [new file with mode: 0644]
src/views/dolphinview.cpp
src/views/dolphinview.h