[tracker/sam/tracker-resource-delete-nested-resources: 230/231] libtracker-sparql: Simplify tracker-resource code with helper function
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sam/tracker-resource-delete-nested-resources: 230/231] libtracker-sparql: Simplify tracker-resource code with helper function
- Date: Wed, 2 Oct 2019 22:45:04 +0000 (UTC)
commit 59376a1610ddaf918d4f171713bf0107df242ca4
Author: Sam Thursfield <sam afuera me uk>
Date: Thu Oct 3 00:04:02 2019 +0200
libtracker-sparql: Simplify tracker-resource code with helper function
src/libtracker-sparql/tracker-resource.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-resource.c b/src/libtracker-sparql/tracker-resource.c
index 8f69be646..4baf70667 100644
--- a/src/libtracker-sparql/tracker-resource.c
+++ b/src/libtracker-sparql/tracker-resource.c
@@ -961,6 +961,13 @@ tracker_resource_compare (TrackerResource *a,
return strcmp (a_priv->identifier, b_priv->identifier);
};
+/* Internal helper. */
+static GList *
+g_list_find_resource (GList *list,
+ TrackerResource *resource) {
+ return g_list_find_custom (list, resource, (GCompareFunc) tracker_resource_compare);
+}
+
/* Helper function for serialization code. This allows you to selectively
* populate 'interned_namespaces' from 'all_namespaces' based on when a
@@ -1039,7 +1046,7 @@ generate_nested_turtle_resource (TrackerResource *resource,
data->all_namespaces))
return;
- if (g_list_find_custom (data->done_list, resource, (GCompareFunc) tracker_resource_compare) == NULL) {
+ if (g_list_find_resource (data->done_list, resource) == NULL) {
data->done_list = g_list_prepend (data->done_list, resource);
generate_turtle (resource, data);
g_string_append (data->string, "\n");
@@ -1345,7 +1352,7 @@ generate_sparql_relation_inserts_foreach (gpointer key,
data->namespaces))
return;
- if (g_list_find_custom (data->done_list, relation, (GCompareFunc) tracker_resource_compare)
== NULL) {
+ if (g_list_find_resource (data->done_list, relation) == NULL) {
data->done_list = g_list_prepend (data->done_list, relation);
generate_sparql_insert_pattern (relation, data);
}
@@ -1368,8 +1375,7 @@ generate_sparql_relation_inserts_foreach (gpointer key,
data->namespaces))
continue;
- if (g_list_find_custom (data->done_list, relation,
- (GCompareFunc) tracker_resource_compare) != NULL)
+ if (g_list_find_resource (data->done_list, relation) != NULL)
continue;
data->done_list = g_list_prepend (data->done_list, relation);
@@ -1429,7 +1435,7 @@ generate_sparql_deletes (TrackerResource *resource,
{
TrackerResourcePrivate *priv = GET_PRIVATE (resource);
- if (g_list_find_custom (data->done_list, resource, (GCompareFunc) tracker_resource_compare) != NULL)
+ if (g_list_find_resource (data->done_list, resource) != NULL)
/* We already processed this resource. */
return;
@@ -1605,7 +1611,7 @@ generate_jsonld_value (const GValue *value,
resource = TRACKER_RESOURCE (g_value_get_object (value));
- if (g_list_find_custom (data->done_list, resource, (GCompareFunc) tracker_resource_compare)
== NULL) {
+ if (g_list_find_resource (data->done_list, resource) == NULL) {
data->done_list = g_list_prepend (data->done_list, resource);
json_builder_begin_object (data->builder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]