[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gap-dev-discuss] Cynthiune : make adding multiple songs to the play
From: |
Philippe Roussel |
Subject: |
Re: [Gap-dev-discuss] Cynthiune : make adding multiple songs to the playlist faster |
Date: |
Sat, 19 May 2012 12:21:16 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 |
Hi Riccardo,
Le 19/05/2012 10:38, Riccardo Mottola a écrit :
> Hi,
>
> at a first glance, I think you end up skipping duplicate song check.
> Furthermore I don't see why the actual code fails. i did not commit it.
Sorry but maybe you should have read and tested the patch :
- duplicate songs are found correctly
- I never said the current code fails
- the ChangeLog entry explains all this
When adding multiple songs the current code calls [Playlist -addSong:],
which in turn calls [Playlist -postNotificationWithSongAsFirst:], for
each song. This is really ineffective.
[Playlist -addSongsInArray:] seems to have be written exactly to solve
this : it checks each file before adding it to the playlist and then
call [Playlist -postNotificationWithSongAsFirst:] one time when done.
Otherwise you can remove [Playlist -addSongsInArray:] altogether.
Thanks,
Philippe
> Philippe Roussel wrote:
>> Hi,
>>
>> While chasing another crash I found that when adding multiple songs to
>> the playlist a notification was sent for every song. By using an
>> existing but previously unused method, the notification is only sent
>> once, when every songs are added.
>>
>> What do you think ?
>>
>> Thanks,
>> Philippe
>>
>> Index: ChangeLog
>> ===================================================================
>> RCS file: /sources/gap/gap/user-apps/Cynthiune/ChangeLog,v
>> retrieving revision 1.46
>> diff -u -r1.46 ChangeLog
>> --- ChangeLog 16 May 2012 16:28:33 -0000 1.46
>> +++ ChangeLog 17 May 2012 10:17:52 -0000
>> @@ -1,3 +1,10 @@
>> +2012-05-17 Philippe Roussel<address@hidden>
>> +
>> + * PlaylistController.m
>> + Optimize adding multiple songs to the playlist by using
>> + [Playlist -addSongsInArray:] : PlaylistChangedNotification
>> + is sent only one time, not for every song added
>> +
>> 2012-05-15 Riccardo Mottola<address@hidden>
>>
>> * PlaylistController.m
>> Index: PlaylistController.m
>> ===================================================================
>> RCS file: /sources/gap/gap/user-apps/Cynthiune/PlaylistController.m,v
>> retrieving revision 1.7
>> diff -u -r1.7 PlaylistController.m
>> --- PlaylistController.m 16 May 2012 16:28:33 -0000 1.7
>> +++ PlaylistController.m 17 May 2012 10:17:52 -0000
>> @@ -506,7 +506,9 @@
>> NSEnumerator *files;
>> NSString *filename;
>> FormatTester *formatTester;
>> + NSMutableArray *songs;
>>
>> + songs = [NSMutableArray array];
>> formatTester = [FormatTester formatTester];
>> files = [filenames objectEnumerator];
>>
>> @@ -525,10 +527,12 @@
>> }
>> else if ([formatTester formatNumberForFile: filename]> -1)
>> {
>> - [playlist addSong: [Song songWithFilename: filename]];
>> + [songs addObject: [Song songWithFilename: filename]];
>> }
>> }
>> }
>> + if ([songs count]> 0)
>> + [playlist addSongsInArray: songs];
>> }
>>
>> - (void) _oPanelDidEnd: (NSOpenPanel *) oPanel
>>
>