[tracker/journal: 3/3] libtracker-data: Store graph as int ID isntead of strdup



commit 4d7228b91d25cb313db5c858777121dee691b786
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Mar 11 13:35:11 2010 +0100

    libtracker-data: Store graph as int ID isntead of strdup

 src/libtracker-data/tracker-data-update.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index e39b2b3..6582b0e 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -82,7 +82,7 @@ struct _TrackerDataUpdateBufferResource {
 struct _TrackerDataUpdateBufferProperty {
 	gchar *name;
 	GValue value;
-	gchar *graph;
+	gint graph;
 	gboolean fts : 1;
 	gboolean date_time : 1;
 };
@@ -133,6 +133,8 @@ static GPtrArray *delete_callbacks = NULL;
 static GPtrArray *commit_callbacks = NULL;
 static GPtrArray *rollback_callbacks = NULL;
 
+static gint ensure_resource_id (const gchar *uri, gboolean    *create);
+
 void
 tracker_data_add_commit_statement_callback (TrackerCommitCallback    callback,
                                             gpointer                 user_data)
@@ -281,7 +283,6 @@ cache_table_free (TrackerDataUpdateBufferTable *table)
 		property = &g_array_index (table->properties, TrackerDataUpdateBufferProperty, i);
 		g_free (property->name);
 		g_value_unset (&property->value);
-		g_free (property->graph);
 	}
 
 	g_array_free (table->properties, TRUE);
@@ -328,7 +329,7 @@ cache_insert_value (const gchar            *table_name,
 
 	property.name = g_strdup (field_name);
 	property.value = *value;
-	property.graph = g_strdup (graph);
+	property.graph = graph != NULL ? ensure_resource_id (graph, NULL) : 0;
 	property.fts = fts;
 	property.date_time = date_time;
 
@@ -359,7 +360,7 @@ cache_delete_value (const gchar            *table_name,
 
 	property.name = g_strdup (field_name);
 	property.value = *value;
-	property.graph = NULL;
+	property.graph = 0;
 	property.fts = fts;
 	property.date_time = date_time;
 
@@ -538,8 +539,8 @@ tracker_data_resource_buffer_flush (GError **error)
 				tracker_db_statement_bind_int (stmt, param++, resource_buffer->id);
 				statement_bind_gvalue (stmt, &param, &property->value);
 
-				if (property->graph) {
-					tracker_db_statement_bind_int (stmt, param++, ensure_resource_id (property->graph, NULL));
+				if (property->graph != 0) {
+					tracker_db_statement_bind_int (stmt, param++, property->graph);
 				} else {
 					tracker_db_statement_bind_null (stmt, param++);
 				}
@@ -652,8 +653,8 @@ tracker_data_resource_buffer_flush (GError **error)
 				} else {
 					statement_bind_gvalue (stmt, &param, &property->value);
 				}
-				if (property->graph) {
-					tracker_db_statement_bind_int (stmt, param++, ensure_resource_id (property->graph, NULL));
+				if (property->graph != 0) {
+					tracker_db_statement_bind_int (stmt, param++, property->graph);
 				} else {
 					tracker_db_statement_bind_null (stmt, param++);
 				}



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