gap-dev-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gap-dev-discuss] Cynthiune : make adding multiple songs to the playlist


From: Philippe Roussel
Subject: [Gap-dev-discuss] Cynthiune : make adding multiple songs to the playlist faster
Date: Thu, 17 May 2012 12:22:35 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]