Revision: 2306
http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2306&view=rev
Author: teuf
Date: 2009-04-05 15:41:56 +0000 (Sun, 05 Apr 2009)
Log Message:
-----------
Avoid O(N^2) behaviour when reading track list from the iPod
Modified Paths:
--------------
libgpod/trunk/ChangeLog
libgpod/trunk/src/itdb_itunesdb.c
libgpod/trunk/src/itdb_private.h
Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog 2009-04-05 15:41:24 UTC (rev 2305)
+++ libgpod/trunk/ChangeLog 2009-04-05 15:41:56 UTC (rev 2306)
@@ -2,6 +2,13 @@
Patch from: Javier Kohen:
+ * src/itdb_itunesdb.c: avoid O(N^2) behaviour in main tracklist
+ parsing.
+
+2009-04-05 Christophe Fergeau <[email protected]>
+
+ Patch from: Javier Kohen:
+
* src/itdb_itunesdb.c: avoid O(N^2) behaviour in playcount reading
2009-04-05 Christophe Fergeau <[email protected]>
Modified: libgpod/trunk/src/itdb_itunesdb.c
===================================================================
--- libgpod/trunk/src/itdb_itunesdb.c 2009-04-05 15:41:24 UTC (rev 2305)
+++ libgpod/trunk/src/itdb_itunesdb.c 2009-04-05 15:41:56 UTC (rev 2306)
@@ -1136,6 +1136,7 @@
{
if (fimp->fcontents) fcontents_free (fimp->fcontents);
g_list_free (fimp->pos_glist);
+ g_list_free (fimp->tracks);
playcounts_free (fimp);
g_free (fimp);
}
@@ -2507,7 +2508,7 @@
g_free (playcount);
}
- itdb_track_add (fimp->itdb, track, -1);
+ fimp->tracks = g_list_prepend(fimp->tracks, track);
return seek;
}
@@ -2674,6 +2675,7 @@
static gboolean parse_tracks (FImport *fimp, glong mhsd_seek)
{
FContents *cts;
+ GList* gl;
glong mhlt_seek, seek;
guint32 nr_tracks, i;
@@ -2721,6 +2723,10 @@
break;
}
}
+ for (gl=fimp->tracks; gl; gl=g_list_next(gl)) {
+ Itdb_Track *track = (Itdb_Track *)gl->data;
+ itdb_track_add (fimp->itdb, track, 0);
+ }
return TRUE;
}
Modified: libgpod/trunk/src/itdb_private.h
===================================================================
--- libgpod/trunk/src/itdb_private.h 2009-04-05 15:41:24 UTC (rev 2305)
+++ libgpod/trunk/src/itdb_private.h 2009-04-05 15:41:56 UTC (rev 2306)
@@ -83,6 +83,7 @@
Itdb_iTunesDB *itdb;
FContents *fcontents;
GList *pos_glist; /* temporary list to store position indicators */
+ GList *tracks; /* temporary list to store tracks */
GList *playcounts; /* contents of Play Counts file */
GTree *idtree; /* temporary tree with track id tree */
GError *error; /* where to report errors to */
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