From 315edcfc41670809524575712e46997573ee2d22 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 6 Jul 2017 21:43:23 +0100 Subject: [PATCH] common/utils: Use a hash table as a set in the recommended way Use g_hash_table_add() so that GHashTable can internally optimise for use as a set, which results in slightly simpler code for the caller, and slightly less memory usage overall. This introduces no functional changes. Signed-off-by: Philip Withnall --- common/flatpak-utils.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index d194e6111..8da39a1ce 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -3606,10 +3606,9 @@ flatpak_repo_generate_appstream (OstreeRepo *repo, GError **error) { g_autoptr(GHashTable) all_refs = NULL; - g_autoptr(GHashTable) arches = NULL; + g_autoptr(GHashTable) arches = NULL; /* (element-type utf8 utf8) */ GHashTableIter iter; gpointer key; - gpointer value; gboolean skip_commit = FALSE; arches = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -3622,7 +3621,7 @@ flatpak_repo_generate_appstream (OstreeRepo *repo, return FALSE; g_hash_table_iter_init (&iter, all_refs); - while (g_hash_table_iter_next (&iter, &key, &value)) + while (g_hash_table_iter_next (&iter, &key, NULL)) { const char *ref = key; const char *arch; @@ -3634,11 +3633,11 @@ flatpak_repo_generate_appstream (OstreeRepo *repo, arch = split[2]; if (!g_hash_table_contains (arches, arch)) - g_hash_table_insert (arches, g_strdup (arch), GINT_TO_POINTER (1)); + g_hash_table_add (arches, g_strdup (arch)); } g_hash_table_iter_init (&iter, arches); - while (g_hash_table_iter_next (&iter, &key, &value)) + while (g_hash_table_iter_next (&iter, &key, NULL)) { GHashTableIter iter2; const char *arch = key; @@ -3663,7 +3662,7 @@ flatpak_repo_generate_appstream (OstreeRepo *repo, appstream_root = flatpak_appstream_xml_new (); g_hash_table_iter_init (&iter2, all_refs); - while (g_hash_table_iter_next (&iter2, &key, &value)) + while (g_hash_table_iter_next (&iter2, &key, NULL)) { const char *ref = key; g_auto(GStrv) split = NULL;