shared: avoid heap allocation in _nm_utils_enum_from_str_full()

In the vast majority of cases is the string for _nm_utils_enum_from_str_full()
short. As we duplicate it for stripping, prefer to clone it on the stack
with nm_strdup_maybe_a().
This commit is contained in:
Thomas Haller 2021-01-14 17:38:10 +01:00
parent e884ef39ed
commit 88a7ec8b14
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -212,8 +212,7 @@ _nm_utils_enum_from_str_full(GType type,
_ASSERT_enum_values_info(type, value_infos);
str_clone = strdup(str);
s = nm_str_skip_leading_spaces(str_clone);
s = nm_strdup_maybe_a(300, nm_str_skip_leading_spaces(str), &str_clone);
g_strchomp(s);
klass = g_type_class_ref(type);