diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-12-19 18:52:32 +0000 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-03-03 18:40:33 +0000 |
commit | 59748c3be03fb4df0005fcc54f6b6267d6b2ada8 (patch) | |
tree | 1daa12f730b533597bbb119e304e45372e0cbbe0 | |
parent | c639b628ec425ac28b79bd48c703fc7115b1fc97 (diff) | |
download | glib-59748c3be03fb4df0005fcc54f6b6267d6b2ada8.tar.gz |
ghash: Document that g_hash_get_[keys|values]() are expensive
And definitely not the right way to iterate over a hash table (as seen
in code in the wild).
https://bugzilla.gnome.org/show_bug.cgi?id=741779
-rw-r--r-- | glib/ghash.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/glib/ghash.c b/glib/ghash.c index 41d05dc6e..78d7f3898 100644 --- a/glib/ghash.c +++ b/glib/ghash.c @@ -1701,6 +1701,10 @@ g_hash_table_size (GHashTable *hash_table) * Retrieves every key inside @hash_table. The returned data is valid * until changes to the hash release those keys. * + * This iterates over every entry in the hash table to build its return value. + * To iterate over the entries in a #GHashTable more efficiently, use a + * #GHashTableIter. + * * Returns: a #GList containing all the keys inside the hash * table. The content of the list is owned by the hash table and * should not be modified or freed. Use g_list_free() when done @@ -1740,6 +1744,10 @@ g_hash_table_get_keys (GHashTable *hash_table) * Note: in the common case of a string-keyed #GHashTable, the return * value of this function can be conveniently cast to (const gchar **). * + * This iterates over every entry in the hash table to build its return value. + * To iterate over the entries in a #GHashTable more efficiently, use a + * #GHashTableIter. + * * You should always free the return result with g_free(). In the * above-mentioned case of a string-keyed hash table, it may be * appropriate to use g_strfreev() if you call g_hash_table_steal_all() @@ -1779,6 +1787,10 @@ g_hash_table_get_keys_as_array (GHashTable *hash_table, * Retrieves every value inside @hash_table. The returned data * is valid until @hash_table is modified. * + * This iterates over every entry in the hash table to build its return value. + * To iterate over the entries in a #GHashTable more efficiently, use a + * #GHashTableIter. + * * Returns: a #GList containing all the values inside the hash * table. The content of the list is owned by the hash table and * should not be modified or freed. Use g_list_free() when done |