Ticket #482 (closed patch: fixed)
Opened 7 years ago
Last modified 7 years ago
mythmusic uses bubble sort when sorting the MusicNode tree.
| Reported by: | eskil <myth@…> | Owned by: | ijr |
|---|---|---|---|
| Priority: | minor | Milestone: | unknown |
| Component: | mythmusic | Version: | |
| Severity: | medium | Keywords: | |
| Cc: | Ticket locked: | no |
Description
After building the tree, AllMusic::resync calls ::sortTree when then happily uses bubblesort, implemented three different places to sort the three. That's not good for performance.
Attachments
Change History
Changed 7 years ago by eskil <myth@…>
- Attachment tree-sorting.patch added
comment:1 Changed 7 years ago by eskil <myth@…>
The attached patch changes metadata.h from using QPtrList<Metadata> and QPtrList<MusicNode?> to two classes, MetadataPtrList? and MusicNodePtrList?, inherited from the QPtrList. These two classes implement the ::compareItems method so the ::sort method (inherited from QPtrList) can be used for sorting.
See http://eskil.org/mythtv/patches/tree-sorting.txt for profile results. Conclusion is, that with my 29010 rows in musicmetadata, a display path of "splitartist artist title album" sorts in <1 secs instead of 5secs. More noticably, a path of "artist title album" descreases from 22secs to <1secs.
comment:3 Changed 7 years ago by danielk
- Status changed from new to closed
- Resolution set to fixed
applied in [7585].
Changed 7 years ago by eskil <myth@…>
- Attachment compare-fix.patch added
Fix to track compare method
comment:4 Changed 7 years ago by eskil <myth@…>
- Status changed from closed to reopened
- Resolution fixed deleted
Daniel, thanks for submitting, but your tightening of MetadataPtrList::compareItem is wrong, it causes descending sort.
I've attached a 1 line fix to make it ascending again.

Patch to switch from bubblesort to QPtrList::sort