mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-29 08:56:15 +01:00
gkeyfile: Move allocation of value until after locale checks have passed
This avoids allocating a copy of the value in the case that it’s for a locale which is uninteresting. This should speed up parsing of key files with large numbers of translations, when only the translations for certain locales are wanted. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
6c70d30f07
commit
5a38dc79f0
@ -1420,8 +1420,6 @@ g_key_file_parse_key_value_pair (GKeyFile *key_file,
|
||||
}
|
||||
}
|
||||
|
||||
value = g_strndup (value_start, value_len);
|
||||
|
||||
/* Is this key a translation? If so, is it one that we care about?
|
||||
*/
|
||||
locale = key_get_locale (key);
|
||||
@ -1432,13 +1430,12 @@ g_key_file_parse_key_value_pair (GKeyFile *key_file,
|
||||
|
||||
pair = g_slice_new (GKeyFileKeyValuePair);
|
||||
pair->key = g_steal_pointer (&key);
|
||||
pair->value = g_steal_pointer (&value);
|
||||
pair->value = g_strndup (value_start, value_len);
|
||||
|
||||
g_key_file_add_key_value_pair (key_file, key_file->current_group, pair);
|
||||
}
|
||||
|
||||
g_free (key);
|
||||
g_free (value);
|
||||
g_free (locale);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user