From 1cab6367b2c4a509689bf2009719b2fcdb836c04 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 12 Dec 2019 11:52:11 +0100 Subject: libnm: don't have G_PARAM_CONSTRUCT properties in NMSetting instances G_PARAM_CONSTRUCT cause to explicitly initialize the property during object construction. This is an unnecessary overhead that we can easily avoid. The overhead is because G_PARAM_CONSTRUCT parameters are always set with g_object_set() before calling constructed(). Even if they are not specified during g_object_new(), in which case it calls set with the property's default value. This also requires g_object_new() to iterate all properties to find and sort the construct properties. NMSetting are supposed to be simple classes. They don't need to have their properties initialized before object construction completes. Especially if the default values are NULL or zero, in which case there is nothing to do. If the default value is not NULL or zero, we need to initialize the field instead in the nm_setting*_init() function. --- libnm-core/nm-setting-sriov.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libnm-core/nm-setting-sriov.c') diff --git a/libnm-core/nm-setting-sriov.c b/libnm-core/nm-setting-sriov.c index 9ef68cce61..88801bd824 100644 --- a/libnm-core/nm-setting-sriov.c +++ b/libnm-core/nm-setting-sriov.c @@ -1217,6 +1217,8 @@ static void nm_setting_sriov_init (NMSettingSriov *setting) { setting->vfs = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_sriov_vf_unref); + + setting->autoprobe_drivers = NM_TERNARY_DEFAULT; } /** @@ -1282,7 +1284,6 @@ nm_setting_sriov_class_init (NMSettingSriovClass *klass) 0, G_MAXUINT32, 0, NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); /** @@ -1370,7 +1371,6 @@ nm_setting_sriov_class_init (NMSettingSriovClass *klass) NM_TERNARY_DEFAULT, NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); -- cgit v1.2.1