[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-multimedia
Subject: Re: Patch: Randomize Standard Playlist (Performance)
From: Oliver Strutynski <olistrut () gmx ! net>
Date: 2001-11-11 17:22:50
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Here's another update for the randomize code (patch against cvs again). The
first patch caused items at the end of the list to be pretty poorly
randomized. The new code does fix this by exchanging two randomly chosen
elements in the playlist - still much faster than the original
implementation. Only problem is that chances are pretty high that _some_ of
the elements at the end of the list remain there. While that does not look
too random, it is exactly what ranomizing should be like.
Now if there only were a better (=faster) way to exchange two listview items.
Moving the items is still rather slow and should not be necessary.
Are there any objections to that patch, any problems? I understand that
shuffle performance is not too high on your priority list, still it does make
a significant difference in the handling of the noatun playlist, when dealing
with a large number of audio files.
Index: playlist.cpp
===================================================================
RCS file:
/home/kde/kdemultimedia/noatun/noatun/modules/splitplaylist/Attic/playlist.cpp,v
retrieving revision 1.28
diff -u -3 -p -r1.28 playlist.cpp
- --- playlist.cpp 2001/06/04 02:19:51 1.28
+++ playlist.cpp 2001/11/11 17:21:44
@@ -153,25 +153,18 @@ void SplitPlaylist::randomize()
// otherwise, the list will get randomized and promptly sorted again
view->setSorting(false);
List *lview = view->listView();
- - // eeeeevil :)
- - QList<void> list;
- - QList<QListViewItem> items;
- - for ( int i = 0; i < lview->childCount(); i++ )
- - {
- - list.append( (void*) i );
- - items.append( lview->itemAtIndex( i ) );
- - }
+
+ // not so evil anymore :)
KRandomSequence seq;
- - seq.randomize( &list );
- -
for ( int i = 0; i < lview->childCount(); i++ )
{
- - lview->moveItem( items.take(), 0L,
- - lview->itemAtIndex( (int) list.take() ) );
+ lview->moveItem( lview->itemAtIndex( (int)
seq.getLong(lview->childCount()) ), 0L,
+ lview->itemAtIndex( (int)
seq.getLong(lview->childCount())));
}
setCurrent( currentItem );
+
}
- --
_____________________________________________________________________
Oliver Strutynski oliver.strutynski@cs.tum.edu
olistrut@gmx.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE77rPvuUAlUEFqtKYRAquTAJwM/L6I5S5sRWhbE2gGHs7aRky5LwCgj27w
jC4+Lt/hoHsvrxO8qc74m0c=
=Jkuh
-----END PGP SIGNATURE-----
_______________________________________________
kde-multimedia mailing list
kde-multimedia@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-multimedia
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic