From c29601818fe141ee5bb578fe30a37cecf914a203 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Sun, 14 Mar 2021 13:57:39 +0000 Subject: [PATCH] gkeyfile: Eliminate strcmp()s when looking up a group node Rather than looking for the group node by comparing each name in the linked list of `GKeyFileGroup` instances, look up the `GKeyFileGroup` in the hash table, then look up its `GList` node by pointer. Signed-off-by: Philip Withnall --- glib/gkeyfile.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c index 2fee51324..229f38784 100644 --- a/glib/gkeyfile.c +++ b/glib/gkeyfile.c @@ -4080,17 +4080,12 @@ g_key_file_lookup_group_node (GKeyFile *key_file, const gchar *group_name) { GKeyFileGroup *group; - GList *tmp; - for (tmp = key_file->groups; tmp != NULL; tmp = tmp->next) - { - group = (GKeyFileGroup *) tmp->data; + group = g_key_file_lookup_group (key_file, group_name); + if (group == NULL) + return NULL; - if (group && group->name && strcmp (group->name, group_name) == 0) - break; - } - - return tmp; + return g_list_find (key_file->groups, group); } static GKeyFileGroup *