forked from AuroraMiddleware/gtk
8c608e9c1c
Instead of one item keeping the item + its position and sorting that list, keep the items in 1 array and put the positions into a 2nd array. This is generally slower while sorting, but allows multiple improvements: 1. We can replace items with keys This allows avoiding multiple slow lookups when using complex comparisons 2. We can keep multiple position arrays This allows doing a sorting in the background without actually emitting items-changed() until the array is completely sorted. 3. The main list tracks the items in the original model So only a single memmove() is necessary there, while the old version had to upgrade the position in every item. Benchmarks: sorting a model of simple strings old new 256,000 items 256ms 268ms 512,000 items 569ms 638ms sorting a model of file trees, directories first, by size old new 64,000 items 350ms 364ms 128,000 items 667ms 691ms removing half the model old new 512,000 items 24ms 15ms 1,024,000 items 49ms 25ms |
||
---|---|---|
.. | ||
a11y | ||
css | ||
gdk | ||
gsk | ||
gtk | ||
performance | ||
reftests | ||
tools | ||
meson.build |