Review Request 111398: Fix O(N^2) complexity issue in KItemListView::slotItemsRemoved
Frank Reininghaus
frank78ac at googlemail.com
Fri Jul 5 18:56:17 BST 2013
> On July 5, 2013, 12:49 p.m., Emmanuel Pescosta wrote:
> > Works for me. Ship it from my side!
> >
> > Maybe we should replace QHash.remove(key) calls by QHash.erase(iterator) calls in KItemListView to avoid expensive rehashing (esp. in setWidgetIndex, moveWidgetToIndex, ...)? What do you think?
> >
> > https://qt-project.org/doc/qt-5.0/qtcore/qhash.html#erase
It's always good to think of such possible problems :-) However, I think that the rehashing can never be extremely expensive here because the hash m_visibleItems cannot contain really many items. That being said, it won't hurt the performance to make such a change. If it doesn't make the code much more complex, I see no reason why it couldn't be done.
- Frank
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/111398/#review35631
-----------------------------------------------------------
On July 5, 2013, 5:53 p.m., Frank Reininghaus wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/111398/
> -----------------------------------------------------------
>
> (Updated July 5, 2013, 5:53 p.m.)
>
>
> Review request for Dolphin.
>
>
> Description
> -------
>
> In a directory which is shown in Dolphin, try the following (where N is a large number > 100000):
>
> touch {1..N}.png
> touch {1..N}.jpg
>
> (wait until all files are shown in the view)
>
> rm *.jpg
>
> This will freeze Dolphin for quite some time (if not, try to increase the number of files). This is because KItemListView::slotItemsRemoved() has a loop over all removed item ranges (100000 in this case), and in each loop, it has another loop that iterates through all items and tries to find visible ones. This is bad because there is always only a small number of visible items, so we better just iterate over those (similar to the approach in KItemListView::slotItemsInserted).
>
>
> Diffs
> -----
>
> dolphin/src/kitemviews/kitemlistview.cpp 2ea6657
>
> Diff: http://git.reviewboard.kde.org/r/111398/diff/
>
>
> Testing
> -------
>
> Dolphin takes a lot less time to remove many item ranges.
>
>
> Thanks,
>
> Frank Reininghaus
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20130705/0acd2f4c/attachment.htm>
More information about the kfm-devel
mailing list