[polari/wip/carlosg/tracker: 15/16] lib: Use TrackerResource "add" API when we know replacing is not necessary



commit 2bf0266babe97303017140304f9255297f71b074
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Feb 24 23:22:12 2019 +0100

    lib: Use TrackerResource "add" API when we know replacing is not necessary
    
    On invariable fields, or those we know have no previous values (eg. a
    new message as an anonymous node), we can use tracker_resource_add*
    API, which avoids deleting previous values. This should speed up
    imports.
    
    This is specially important on the "rdf:type" property, as Tracker
    implicitly deletes resources when all rdf:types are gone, so we are
    essentially deleting and creating elements for channels/users very
    frequently.

 src/lib/polari-message.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/lib/polari-message.c b/src/lib/polari-message.c
index 219eced..145e23a 100644
--- a/src/lib/polari-message.c
+++ b/src/lib/polari-message.c
@@ -136,8 +136,8 @@ create_account_resource (const char *id)
 
   res = tracker_resource_new (uri);
 
-  tracker_resource_set_uri (res, "rdf:type", "polari:Account");
-  tracker_resource_set_string (res, "polari:id", id);
+  tracker_resource_add_uri (res, "rdf:type", "polari:Account");
+  tracker_resource_add_string (res, "polari:id", id);
 
   g_free (uri);
 
@@ -156,10 +156,10 @@ create_channel_resource (const char *name,
 
   res = tracker_resource_new (uri);
 
-  tracker_resource_set_uri (res, "rdf:type", is_room ? "polari:Room"
+  tracker_resource_add_uri (res, "rdf:type", is_room ? "polari:Room"
                                                      : "polari:Conversation");
-  tracker_resource_set_string (res, "polari:name", name);
-  tracker_resource_set_take_relation (res, "polari:account",
+  tracker_resource_add_string (res, "polari:name", name);
+  tracker_resource_add_take_relation (res, "polari:account",
                                       create_account_resource (account_id));
 
   g_free (uri);
@@ -180,7 +180,7 @@ create_sender_resource (const char *nick,
 
   res = tracker_resource_new (uri);
 
-  tracker_resource_set_uri (res, "rdf:type", is_self ? "polari:SelfContact"
+  tracker_resource_add_uri (res, "rdf:type", is_self ? "polari:SelfContact"
                                                      : "polari:Contact");
   tracker_resource_set_string (res, "polari:nick", nick);
 


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