[tracker/wip/carlosg/update-perf: 58/72] core: Delay GHashTable creation
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/update-perf: 58/72] core: Delay GHashTable creation
- Date: Tue, 30 Aug 2022 15:39:42 +0000 (UTC)
commit 7573992a419f8e16ab9292863c53c4124c3c6101
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Aug 18 23:46:01 2022 +0200
core: Delay GHashTable creation
We can avoid this small piece of busywork until when it's needed.
May help with insertion of simple TrackerResources.
src/libtracker-sparql/core/tracker-data-update.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-sparql/core/tracker-data-update.c
b/src/libtracker-sparql/core/tracker-data-update.c
index b3cfeb5e7..b5290dfa1 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -1391,7 +1391,7 @@ graph_buffer_free (TrackerDataUpdateBufferGraph *graph)
static void resource_buffer_free (TrackerDataUpdateBufferResource *resource)
{
- g_hash_table_unref (resource->predicates);
+ g_clear_pointer (&resource->predicates, g_hash_table_unref);
g_ptr_array_free (resource->types, TRUE);
resource->types = NULL;
@@ -1786,6 +1786,12 @@ get_property_values (TrackerData *data,
const gchar *database;
GArray *old_values;
+ if (!data->resource_buffer->predicates) {
+ data->resource_buffer->predicates =
+ g_hash_table_new_full (NULL, NULL, g_object_unref,
+ (GDestroyNotify) g_array_unref);
+ }
+
old_values = g_hash_table_lookup (data->resource_buffer->predicates, property);
if (old_values != NULL)
return old_values;
@@ -2473,7 +2479,6 @@ resource_buffer_switch (TrackerData *data,
} else {
resource_buffer->types = rdf_types;
}
- resource_buffer->predicates = g_hash_table_new_full (g_direct_hash, g_direct_equal,
g_object_unref, (GDestroyNotify) g_array_unref);
resource_buffer->graph = graph_buffer;
g_hash_table_insert (graph_buffer->resources, &resource_buffer->id, resource_buffer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]