[tracker/wip/carlosg/update-perf: 4/18] core: Delay GHashTable creation
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/update-perf: 4/18] core: Delay GHashTable creation
- Date: Tue, 23 Aug 2022 09:43:13 +0000 (UTC)
commit 45f903796dc4172ef60a1d9494c47ca4a1c32286
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 e64ccfbc3..b44e64f55 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -1388,7 +1388,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;
@@ -1783,6 +1783,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;
@@ -2468,7 +2474,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]