[maemo-commits] [maemo-commits] r17686 - in projects/haf/trunk/totem-pl-parser/debian: . patches
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Mar 16 11:36:30 EET 2009
- Previous message: [maemo-commits] r17685 - in projects/haf/trunk/libmatchbox2: . matchbox/core
- Next message: [maemo-commits] r17687 - projects/haf/tags/totem-pl-parser
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: ifrade Date: 2009-03-16 11:36:27 +0200 (Mon, 16 Mar 2009) New Revision: 17686 Added: projects/haf/trunk/totem-pl-parser/debian/patches/01-pls-speedup.patch Modified: projects/haf/trunk/totem-pl-parser/debian/changelog Log: Added patch to speed up PLS parsing Modified: projects/haf/trunk/totem-pl-parser/debian/changelog =================================================================== --- projects/haf/trunk/totem-pl-parser/debian/changelog 2009-03-13 17:56:17 UTC (rev 17685) +++ projects/haf/trunk/totem-pl-parser/debian/changelog 2009-03-16 09:36:27 UTC (rev 17686) @@ -1,3 +1,10 @@ +totem-pl-parser (2.25.92-2maemo1) maemo; urgency=low + + * Added patch in debian package to speed up pls parsing + * Fixes: NB#101704 ... unable to parse huge playlist + + -- Ivan Frade <ivan.frade at nokia.com> Tue, 16 Mar 2009 11:32:46 +0200 + totem-pl-parser (2.25.92-1maemo1) maemo; urgency=low * Synchronized with upstream -r321 Added: projects/haf/trunk/totem-pl-parser/debian/patches/01-pls-speedup.patch =================================================================== --- projects/haf/trunk/totem-pl-parser/debian/patches/01-pls-speedup.patch 2009-03-13 17:56:17 UTC (rev 17685) +++ projects/haf/trunk/totem-pl-parser/debian/patches/01-pls-speedup.patch 2009-03-16 09:36:27 UTC (rev 17686) @@ -0,0 +1,126 @@ +Index: plparse/totem-pl-parser-pls.c +=================================================================== +--- plparse/totem-pl-parser-pls.c (revisión: 324) ++++ plparse/totem-pl-parser-pls.c (copia de trabajo) +@@ -156,7 +156,10 @@ + char *split_char, *playlist_title; + gboolean dos_mode = FALSE; + gboolean fallback; ++ GHashTable *entries; + ++ entries = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); ++ + /* figure out whether we're a unix pls or dos pls */ + if (strstr(contents,"\x0d") == NULL) { + split_char = "\n"; +@@ -168,6 +171,7 @@ + + /* [playlist] */ + i = 0; ++ num_entries = 0; + playlist_title = NULL; + + /* Ignore empty lines */ +@@ -191,24 +195,44 @@ + NULL); + } + +- /* numberofentries=? */ +- num_entries = totem_pl_parser_read_ini_line_int (lines, "numberofentries"); ++ /* Load the file in hash table to speed up the later processing */ ++ for (i = 0; lines[i] != NULL; i++) { ++ char **bits; ++ char *value; ++ gint len; + +- if (num_entries == -1) { +- num_entries = 0; ++ if (totem_pl_parser_line_is_empty (lines[i])) ++ continue; ++ ++ if (lines[i][0] == '#' || lines[i][0] == '[') ++ continue; ++ ++ bits = g_strsplit (lines[i], "=", 2); ++ if (bits[0] == NULL || bits [1] == NULL) { ++ g_strfreev (bits); ++ continue; ++ } + +- for (i = 0; lines[i] != NULL; i++) { +- if (totem_pl_parser_line_is_empty (lines[i])) +- continue; ++ if (g_ascii_strncasecmp (g_strchug (bits[0]), ++ "file", ++ (gsize)strlen ("file")) == 0) { ++ num_entries++; ++ } + +- if (g_ascii_strncasecmp (g_strchug (lines[i]), "file", (gsize)strlen ("file")) == 0) +- num_entries++; +- } ++ len = strlen (bits[1]); ++ value = g_strdup (bits[1]); ++ if (dos_mode && len >= 2 && value[len-2] == '\r') { ++ value[len-2] = '\n'; ++ value[len-1] = '\0'; ++ } + +- if (num_entries == 0) +- goto bail; +- } ++ g_hash_table_insert (entries, ++ g_ascii_strdown (bits[0], strlen (bits[0])), ++ value); ++ g_strfreev (bits); ++ } + ++ + /* Base? */ + if (_base_file == NULL) + base_file = g_file_get_parent (file); +@@ -229,20 +253,18 @@ + /* Genre is our own little extension */ + genre_key = g_strdup_printf ("genre%d", i); + +- file_str = totem_pl_parser_read_ini_line_string (lines, (const char*)file_key, dos_mode); +- title = totem_pl_parser_read_ini_line_string (lines, (const char*)title_key, dos_mode); +- genre = totem_pl_parser_read_ini_line_string (lines, (const char*)genre_key, dos_mode); +- length = totem_pl_parser_read_ini_line_string (lines, (const char*)length_key, dos_mode); + ++ file_str = g_hash_table_lookup (entries, file_key); ++ title = g_hash_table_lookup (entries, title_key); ++ genre = g_hash_table_lookup (entries, genre_key); ++ length = g_hash_table_lookup (entries, length_key); ++ + g_free (file_key); + g_free (title_key); + g_free (genre_key); + g_free (length_key); + + if (file_str == NULL) { +- g_free (title); +- g_free (genre); +- g_free (length); + continue; + } + +@@ -289,10 +311,6 @@ + } + + parser->priv->fallback = fallback; +- g_free (file_str); +- g_free (title); +- g_free (genre); +- g_free (length); + } + + if (playlist_title != NULL) +@@ -302,6 +320,7 @@ + + bail: + g_free (playlist_title); ++ g_hash_table_destroy (entries); + g_strfreev (lines); + + return retval;
- Previous message: [maemo-commits] r17685 - in projects/haf/trunk/libmatchbox2: . matchbox/core
- Next message: [maemo-commits] r17687 - projects/haf/tags/totem-pl-parser
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]