[tracker/signals] tracker-store: Reuse string chunk during event handling



commit 358f1f4ba6760baa8869bcb5cd89691bad2bf2da
Author: Jürg Billeter <j bitron ch>
Date:   Wed Jun 30 11:16:30 2010 +0200

    tracker-store: Reuse string chunk during event handling

 src/tracker-store/tracker-events.c         |    2 +-
 src/tracker-store/tracker-resource-class.c |   25 ++++---------------------
 2 files changed, 5 insertions(+), 22 deletions(-)
---
diff --git a/src/tracker-store/tracker-events.c b/src/tracker-store/tracker-events.c
index 5bfc215..4359659 100644
--- a/src/tracker-store/tracker-events.c
+++ b/src/tracker-store/tracker-events.c
@@ -72,7 +72,7 @@ prepare_event_for_rdf_type (EventsPrivate *private,
 	}
 
 	if (!private->chunk) {
-		private->chunk = g_string_chunk_new (strlen (uri) + 10);
+		private->chunk = g_string_chunk_new (4096);
 	}
 
 	event.type = type;
diff --git a/src/tracker-store/tracker-resource-class.c b/src/tracker-store/tracker-resource-class.c
index 666102b..e2a904d 100644
--- a/src/tracker-store/tracker-resource-class.c
+++ b/src/tracker-store/tracker-resource-class.c
@@ -43,7 +43,6 @@ typedef struct {
 	gchar *dbus_path;
 	GHashTable *adds_table, *ups_table, *dels_table;
 	GArray *ups;
-	GStringChunk *changed_strings;
 	DBusConnection *connection;
 } TrackerResourceClassPrivate;
 
@@ -236,11 +235,6 @@ tracker_resource_class_emit_events (TrackerResourceClass  *object)
 		priv->dels_table = NULL;
 	}
 
-	if (priv->changed_strings) {
-		g_string_chunk_free (priv->changed_strings);
-		priv->changed_strings = NULL;
-	}
-
 }
 
 
@@ -303,43 +297,32 @@ tracker_resource_class_add_event (TrackerResourceClass  *object,
 
 	priv = TRACKER_RESOURCE_CLASS_GET_PRIVATE (object);
 
-	if (!priv->changed_strings) {
-		/* allocate in chunks of 4K */
-		priv->changed_strings = g_string_chunk_new (4096);
-	}
-
 	switch (type) {
 	case TRACKER_DBUS_EVENTS_TYPE_ADD:
 
-		n_uri = g_string_chunk_insert_const (priv->changed_strings, uri);
-
 		if (!priv->adds_table) {
 			priv->adds_table = g_hash_table_new (NULL, NULL);
 		}
 
-		g_hash_table_insert (priv->adds_table, n_uri, GINT_TO_POINTER (TRUE));
+		g_hash_table_insert (priv->adds_table, uri, GINT_TO_POINTER (TRUE));
 		break;
 	case TRACKER_DBUS_EVENTS_TYPE_UPDATE:
 
-		n_uri = g_string_chunk_insert_const (priv->changed_strings, uri);
-
 		if (!priv->ups_table) {
 			priv->ups_table = g_hash_table_new (NULL, NULL);
 		}
 
-		hash_key = (gpointer) ((gsize) n_uri ^ (gsize) predicate);
+		hash_key = (gpointer) ((gsize) uri ^ (gsize) predicate);
 
-		g_hash_table_insert (priv->ups_table, hash_key, n_uri);
+		g_hash_table_insert (priv->ups_table, hash_key, uri);
 		break;
 	case TRACKER_DBUS_EVENTS_TYPE_DELETE:
 
-		n_uri = g_string_chunk_insert_const (priv->changed_strings, uri);
-
 		if (!priv->dels_table) {
 			priv->dels_table = g_hash_table_new (NULL, NULL);
 		}
 
-		g_hash_table_insert (priv->dels_table, n_uri, GINT_TO_POINTER (TRUE));
+		g_hash_table_insert (priv->dels_table, uri, GINT_TO_POINTER (TRUE));
 		break;
 	default:
 		break;



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