[tracker/wip/carlosg/update-perf: 46/61] core: Shuffle graph URI expansion




commit 6ef24252e0b3964119bb0893040fad9f47f1db81
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Aug 18 23:26:48 2022 +0200

    core: Shuffle graph URI expansion
    
    Since the function it is being expanded from can be called
    recursively, on deeper iterations it would pointessly try to
    expand the URI again.
    
    Do it from the toplevel function, so it's done once for the
    whole TrackerResource update.

 src/libtracker-sparql/core/tracker-data-update.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-sparql/core/tracker-data-update.c 
b/src/libtracker-sparql/core/tracker-data-update.c
index 4de63971d..e64ccfbc3 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -3419,7 +3419,7 @@ update_resource_property (TrackerData      *data,
 
 static gboolean
 update_resource_single (TrackerData      *data,
-                        const gchar      *graph,
+                        const gchar      *graph_uri,
                         TrackerResource  *resource,
                         GHashTable       *visited,
                         GHashTable       *bnodes,
@@ -3430,7 +3430,6 @@ update_resource_single (TrackerData      *data,
        GError *inner_error = NULL;
        const gchar *subject_str;
        TrackerRowid subject;
-       gchar *graph_uri = NULL;
        gboolean is_bnode = FALSE;
 
        if (tracker_resource_is_blank_node (resource)) {
@@ -3458,12 +3457,6 @@ update_resource_single (TrackerData      *data,
 
        properties = tracker_resource_get_properties (resource);
 
-       if (graph) {
-               tracker_data_manager_expand_prefix (data->manager,
-                                                   graph, NULL, NULL,
-                                                   &graph_uri);
-       }
-
        /* Handle rdf:type first */
        if (g_list_find_custom (properties, "rdf:type", (GCompareFunc) g_strcmp0)) {
                update_resource_property (data, graph_uri, resource,
@@ -3511,7 +3504,6 @@ update_resource_single (TrackerData      *data,
 
 out:
        g_list_free (properties);
-       g_free (graph_uri);
 
        if (inner_error) {
                g_propagate_error (error, inner_error);
@@ -3533,15 +3525,23 @@ tracker_data_update_resource (TrackerData      *data,
                               GError          **error)
 {
        gboolean retval;
+       gchar *graph_uri = NULL;
 
        if (bnodes)
                g_hash_table_ref (bnodes);
        else
                bnodes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) 
tracker_rowid_free);
 
-       retval = update_resource_single (data, graph, resource, visited, bnodes, NULL, error);
+       if (graph) {
+               tracker_data_manager_expand_prefix (data->manager,
+                                                   graph, NULL, NULL,
+                                                   &graph_uri);
+       }
+
+       retval = update_resource_single (data, graph_uri, resource, visited, bnodes, NULL, error);
 
        g_hash_table_unref (bnodes);
+       g_free (graph_uri);
 
        return retval;
 }


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