[tracker/class-signal: 15/61] tracker-store: class-signals: Performance optimization at create & delete



commit 6c86d72af58e7353cec5bff6c53afdc0344b3ed2
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Aug 19 14:12:47 2010 +0200

    tracker-store: class-signals: Performance optimization at create & delete

 src/tracker-store/tracker-events.c |   64 ++++++++++++++++++++----------------
 1 files changed, 36 insertions(+), 28 deletions(-)
---
diff --git a/src/tracker-store/tracker-events.c b/src/tracker-store/tracker-events.c
index f794be7..042eaf8 100644
--- a/src/tracker-store/tracker-events.c
+++ b/src/tracker-store/tracker-events.c
@@ -71,22 +71,26 @@ tracker_events_add_insert (gint         graph_id,
 		/* Resource create
 		 * In case of create, object is the rdf:type */
 		if (is_allowed (private, NULL, object_id)) {
-			const gchar *uri;
-
-			/* Double hashtable lookup can be optimized: the class might also be
-			 * in rdf_types (need to check this) */
-
-			uri = tracker_ontologies_get_uri_by_id (object_id);
-			if (uri) {
-				TrackerClass *class;
-				class = tracker_ontologies_get_class_by_uri (uri);
-				if (class) {
-					tracker_class_add_insert_event (class,
-					                                subject_id,
-					                                pred_id,
-					                                object_id);
+			TrackerClass *class = NULL;
+
+			if (rdf_types->len == 1 && tracker_class_get_id (rdf_types->pdata[0]) == object_id) {
+				class = rdf_types->pdata[0];
+			} else {
+				if (object == NULL) {
+					const gchar *uri = tracker_ontologies_get_uri_by_id (object_id);
+					if (uri != NULL)
+						class = tracker_ontologies_get_class_by_uri (uri);
+				} else {
+					class = tracker_ontologies_get_class_by_uri (object);
 				}
 			}
+
+			if (class) {
+				tracker_class_add_insert_event (class,
+				                                subject_id,
+				                                pred_id,
+				                                object_id);
+			}
 		}
 	} else {
 		guint i;
@@ -126,22 +130,26 @@ tracker_events_add_delete (gint         graph_id,
 		/* Resource delete
 		 * In case of delete, object is the rdf:type */
 		if (is_allowed (private, NULL, object_id)) {
-			const gchar *uri;
-
-			/* Double hashtable lookup can be optimized: the class might also be
-			 * in rdf_types (need to check this) */
-
-			uri = tracker_ontologies_get_uri_by_id (object_id);
-			if (uri) {
-				TrackerClass *class;
-				class = tracker_ontologies_get_class_by_uri (uri);
-				if (class) {
-					tracker_class_add_delete_event (class,
-					                                subject_id,
-					                                pred_id,
-					                                object_id);
+			TrackerClass *class = NULL;
+
+			if (rdf_types->len == 1 && tracker_class_get_id (rdf_types->pdata[0]) == object_id) {
+				class = rdf_types->pdata[0];
+			} else {
+				if (object == NULL) {
+					const gchar *uri = tracker_ontologies_get_uri_by_id (object_id);
+					if (uri != NULL)
+						class = tracker_ontologies_get_class_by_uri (uri);
+				} else {
+					class = tracker_ontologies_get_class_by_uri (object);
 				}
 			}
+
+			if (class) {
+				tracker_class_add_delete_event (class,
+				                                subject_id,
+				                                pred_id,
+				                                object_id);
+			}
 		}
 	} else {
 		guint i;



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