Revision: 2305
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2305&view=rev
Author:   teuf
Date:     2009-04-05 15:41:24 +0000 (Sun, 05 Apr 2009)

Log Message:
-----------
Optimize playcount reading

Modified Paths:
--------------
    libgpod/trunk/ChangeLog
    libgpod/trunk/src/itdb_itunesdb.c

Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog     2009-04-05 15:40:56 UTC (rev 2304)
+++ libgpod/trunk/ChangeLog     2009-04-05 15:41:24 UTC (rev 2305)
@@ -2,6 +2,12 @@
 
        Patch from: Javier Kohen:
 
+       * src/itdb_itunesdb.c: avoid O(N^2) behaviour in playcount reading
+
+2009-04-05  Christophe Fergeau  <[email protected]>
+
+       Patch from: Javier Kohen:
+
        * src/itdb_itunesdb.c: rename playcount_get_next to
        playcount_take_next which is a more descriptive name
 

Modified: libgpod/trunk/src/itdb_itunesdb.c
===================================================================
--- libgpod/trunk/src/itdb_itunesdb.c   2009-04-05 15:40:56 UTC (rev 2304)
+++ libgpod/trunk/src/itdb_itunesdb.c   2009-04-05 15:41:24 UTC (rev 2305)
@@ -881,6 +881,7 @@
 /* called by init_playcounts */
 static gboolean playcounts_read (FImport *fimp, FContents *cts)
 {
+    GList* playcounts = NULL;
     guint32 header_length, entry_length, entry_num, i=0;
 
     g_return_val_if_fail (fimp, FALSE);
@@ -952,7 +953,7 @@
        check_seek (cts, seek, entry_length);
        CHECK_ERROR (fimp, FALSE);      
 
-       fimp->playcounts = g_list_append (fimp->playcounts, playcount);
+       playcounts = g_list_prepend (playcounts, playcount);
        playcount->playcount = get32lint (cts, seek);   
        mac_time = get32lint (cts, seek+4);
        playcount->time_played = device_time_mac_to_time_t (fimp->itdb->device, 
mac_time);
@@ -983,6 +984,7 @@
 
        }
     }
+    fimp->playcounts = g_list_reverse(playcounts);
     return TRUE;
 }
 
@@ -990,6 +992,7 @@
 /* called by init_playcounts */
 static gboolean itunesstats_read (FImport *fimp, FContents *cts)
 {
+    GList* playcounts;
     guint32 entry_num, i=0;
     glong seek;
 
@@ -1016,7 +1019,7 @@
            return FALSE;
        }
 
-       fimp->playcounts = g_list_append (fimp->playcounts, playcount);
+       playcounts = g_list_prepend (playcounts, playcount);
        /* NOTE:
         *
         * The iPod (firmware 1.3, 2.0, ...?) doesn't seem to use the
@@ -1041,6 +1044,7 @@
 
        seek += entry_length;
     }
+    fimp->playcounts = g_list_reverse(playcounts);
     return TRUE;
 }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to