gkeyfile: Avoid an unnecessary strcmp()

As the groups are disambiguated by name via the `groups` hash table,
there is guaranteed to be at most one `GKeyFileGroup` instance per group
name, which means they can be compared for equality by `GKeyFileGroup`
pointer, rather than needing a `strcmp()`.

This speeds up key file parsing in all cases.

oss-fuzz#31796

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2021-03-14 13:49:28 +00:00
parent 960030712d
commit f71db39284

View File

@ -1404,8 +1404,7 @@ g_key_file_parse_key_value_pair (GKeyFile *key_file,
if (key_file->current_group
&& key_file->current_group->name
&& strcmp (key_file->start_group->name,
key_file->current_group->name) == 0
&& key_file->start_group == key_file->current_group
&& strcmp (key, "Encoding") == 0)
{
if (g_ascii_strcasecmp (value, "UTF-8") != 0)