mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
GResources: use g_hash_table_get_keys_as_array()
Replace the hand-written equivalent of this with the call to the GHashTable built-in version to save a few lines of code. The GResource code was written a couple of years before this function existed. Similarly, replace a set-mode usage of g_hash_table_insert() with a call to g_hash_table_add(). https://bugzilla.gnome.org/show_bug.cgi?id=765668
This commit is contained in:
parent
05e5da9a83
commit
3c7c0af1c9
@ -810,7 +810,7 @@ g_resources_enumerate_children (const gchar *path,
|
|||||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||||
|
|
||||||
for (i = 0; children[i] != NULL; i++)
|
for (i = 0; children[i] != NULL; i++)
|
||||||
g_hash_table_insert (hash, children[i], children[i]);
|
g_hash_table_add (hash, children[i]);
|
||||||
g_free (children);
|
g_free (children);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -826,18 +826,8 @@ g_resources_enumerate_children (const gchar *path,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
children = (gchar **) g_hash_table_get_keys_as_array (hash, NULL);
|
||||||
const char *key;
|
g_hash_table_steal_all (hash);
|
||||||
guint n_children;
|
|
||||||
n_children = g_hash_table_size (hash);
|
|
||||||
children = g_new (char *, n_children + 1);
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, hash);
|
|
||||||
while (g_hash_table_iter_next (&iter, (gpointer *)&key, NULL))
|
|
||||||
children[i++] = g_strdup (key);
|
|
||||||
children[i++] = NULL;
|
|
||||||
|
|
||||||
g_hash_table_destroy (hash);
|
g_hash_table_destroy (hash);
|
||||||
|
|
||||||
return children;
|
return children;
|
||||||
|
Loading…
Reference in New Issue
Block a user