[tracker/wip/carlosg/sparql1.1: 2/56] libtracker-data: Shuffle code



commit 798fdc18f5d9b118232009fa3be1d422241c5c79
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Feb 28 23:12:14 2019 +0100

    libtracker-data: Shuffle code
    
    We need those variables in the first place in all paths, just query
    them upfront.

 src/libtracker-data/tracker-data-update.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 463fbb42b..035ef59ae 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2551,11 +2551,13 @@ tracker_data_delete_statement (TrackerData  *data,
                }
        } else {
                gint pred_id = 0, graph_id = 0, object_id = 0;
-               gboolean tried = FALSE;
                TrackerProperty *field;
 
+               graph_id = (graph != NULL ? query_resource_id (data, graph) : 0);
                field = tracker_ontologies_get_property_by_uri (ontologies, predicate);
                if (field != NULL) {
+                       pred_id = tracker_property_get_id (field);
+
                        if (!tracker_property_get_transient (field)) {
                                data->has_persistent = TRUE;
                        }
@@ -2563,11 +2565,7 @@ tracker_data_delete_statement (TrackerData  *data,
                        change = delete_metadata_decomposed (data, field, object, 0, error);
                        if (!data->in_journal_replay && change && !tracker_property_get_transient (field)) {
                                if (tracker_property_get_data_type (field) == TRACKER_PROPERTY_TYPE_RESOURCE) 
{
-
-                                       graph_id = (graph != NULL ? query_resource_id (data, graph) : 0);
-                                       pred_id = tracker_property_get_id (field);
                                        object_id = query_resource_id (data, object);
-                                       tried = TRUE;
 
 #ifndef DISABLE_JOURNAL
                                        tracker_db_journal_append_delete_statement_id (data->journal_writer,
@@ -2577,10 +2575,7 @@ tracker_data_delete_statement (TrackerData  *data,
                                                                                       object_id);
 #endif /* DISABLE_JOURNAL */
                                } else {
-                                       pred_id = tracker_property_get_id (field);
-                                       graph_id = (graph != NULL ? query_resource_id (data, graph) : 0);
                                        object_id = 0;
-                                       tried = TRUE;
 
 #ifndef DISABLE_JOURNAL
                                        if (!tracker_property_get_force_journal (field) &&
@@ -2611,15 +2606,6 @@ tracker_data_delete_statement (TrackerData  *data,
                        return;
                }
 
-               if (!tried) {
-                       graph_id = (graph != NULL ? query_resource_id (data, graph) : 0);
-                       if (field == NULL) {
-                               pred_id = tracker_data_query_resource_id (data->manager, iface, predicate);
-                       } else {
-                               pred_id = tracker_property_get_id (field);
-                       }
-               }
-
                if (data->delete_callbacks && change) {
                        guint n;
                        for (n = 0; n < data->delete_callbacks->len; n++) {


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