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 <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2021-03-14 13:57:39 +00:00
parent cba8d59737
commit c29601818f

View File

@ -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 *