Skip to content

Commit 9f3d051

Browse files
committed
Use iterator to get keys from hash table, does not allocate.
1 parent 1de54af commit 9f3d051

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

mono/metadata/unity-memory-info.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ static void CollectImageMetaData(MonoImage* image, gpointer value, CollectMetada
6363

6464
if (image->dynamic)
6565
{
66+
GHashTableIter iter;
67+
gpointer key;
6668
MonoDynamicImage* dynamicImage = (MonoDynamicImage*)image;
67-
GList* types = g_hash_table_get_keys(dynamicImage->typeref);
68-
GList* type;
6969

70-
for (type = types; type != NULL; type = type->next)
70+
g_hash_table_iter_init(&iter, dynamicImage->typeref);
71+
72+
while (g_hash_table_iter_next(&iter, &key, NULL))
7173
{
72-
MonoType* monoType = (MonoType*)type->data;
74+
MonoType* monoType = (MonoType*)key;
7375
MonoClass* klass = mono_type_get_class(monoType);
7476

7577
if (klass)

0 commit comments

Comments
 (0)