[glib: 3/17] gkeyfile: Avoid an unnecessary strcmp()
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 3/17] gkeyfile: Avoid an unnecessary strcmp()
- Date: Tue, 2 Nov 2021 11:08:16 +0000 (UTC)
commit f71db392845ba18457e0e5274ba733afd60edcce
Author: Philip Withnall <pwithnall endlessos org>
Date: Sun Mar 14 13:49:28 2021 +0000
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>
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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]