From f71db392845ba18457e0e5274ba733afd60edcce Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Sun, 14 Mar 2021 13:49:28 +0000 Subject: [PATCH] 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 --- glib/gkeyfile.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c index f1b7f961d..9dd806cb7 100644 --- a/glib/gkeyfile.c +++ b/glib/gkeyfile.c @@ -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)