[tracker/wip/carlosg/libtracker-common-cleanup: 1/3] libtracker-fts: Avoid double conversion of data structures




commit d2f2af51a4fb5404a0778526e11e9a7c288244b9
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Sep 8 13:42:31 2020 +0200

    libtracker-fts: Avoid double conversion of data structures
    
    We accumulate on a list, just to transform to a gchar**, just build the
    latter right away.

 src/libtracker-fts/tracker-fts.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-fts/tracker-fts.c b/src/libtracker-fts/tracker-fts.c
index 079d83a3c..1cb5041fe 100644
--- a/src/libtracker-fts/tracker-fts.c
+++ b/src/libtracker-fts/tracker-fts.c
@@ -38,24 +38,30 @@ int sqlite3_fts5_init ();
 static gchar **
 get_fts_properties (GHashTable  *tables)
 {
-       GList *table_columns, *columns;
-       gchar **property_names;
+       GList *table_columns;
+       GArray *property_names;
        GList *keys, *l;
 
-       columns = NULL;
        keys = g_hash_table_get_keys (tables);
        keys = g_list_sort (keys, (GCompareFunc) strcmp);
 
+       property_names = g_array_new (TRUE, FALSE, sizeof (gchar *));
+
        for (l = keys; l; l = l->next) {
                table_columns = g_hash_table_lookup (tables, l->data);
-               columns = g_list_concat (columns, g_list_copy (table_columns));
+
+               while (table_columns) {
+                       gchar *str;
+
+                       str = g_strdup (table_columns->data);
+                       g_array_append_val (property_names, str);
+                       table_columns = table_columns->next;
+               }
        }
 
-       property_names = tracker_glist_to_string_list (columns);
-       g_list_free (columns);
        g_list_free (keys);
 
-       return property_names;
+       return (gchar **) g_array_free (property_names, FALSE);
 }
 
 gboolean


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