[tracker/wip/carlosg/update-perf: 47/61] core: Delay GHashTable creation




commit 05a4ad1a94ea4738e00c606bb6a04a3481b8258a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Aug 18 23:46:01 2022 +0200

    core: Delay GHashTable creation
    
    We can avoid this small piece of busywork until when it's needed.
    May help with insertion of simple TrackerResources.

 src/libtracker-sparql/core/tracker-data-update.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-sparql/core/tracker-data-update.c 
b/src/libtracker-sparql/core/tracker-data-update.c
index e64ccfbc3..b44e64f55 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -1388,7 +1388,7 @@ graph_buffer_free (TrackerDataUpdateBufferGraph *graph)
 
 static void resource_buffer_free (TrackerDataUpdateBufferResource *resource)
 {
-       g_hash_table_unref (resource->predicates);
+       g_clear_pointer (&resource->predicates, g_hash_table_unref);
 
        g_ptr_array_free (resource->types, TRUE);
        resource->types = NULL;
@@ -1783,6 +1783,12 @@ get_property_values (TrackerData      *data,
        const gchar *database;
        GArray *old_values;
 
+       if (!data->resource_buffer->predicates) {
+               data->resource_buffer->predicates =
+                       g_hash_table_new_full (NULL, NULL, g_object_unref,
+                                              (GDestroyNotify) g_array_unref);
+       }
+
        old_values = g_hash_table_lookup (data->resource_buffer->predicates, property);
        if (old_values != NULL)
                return old_values;
@@ -2468,7 +2474,6 @@ resource_buffer_switch (TrackerData   *data,
                } else {
                        resource_buffer->types = rdf_types;
                }
-               resource_buffer->predicates = g_hash_table_new_full (g_direct_hash, g_direct_equal, 
g_object_unref, (GDestroyNotify) g_array_unref);
                resource_buffer->graph = graph_buffer;
 
                g_hash_table_insert (graph_buffer->resources, &resource_buffer->id, resource_buffer);


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