summaryrefslogtreecommitdiff
path: root/libnm-core/nm-setting-vpn.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-09-22 08:53:06 +0200
committerThomas Haller <thaller@redhat.com>2019-09-30 08:23:19 +0200
commit3f36f6915629d9a98f52fb266f82274785bb49c6 (patch)
tree3990a68937ae81b93c818662771b9d4acffd7303 /libnm-core/nm-setting-vpn.c
parentf36a0d408b1ffa7609fb53de8680cdf26153ba12 (diff)
downloadNetworkManager-3f36f6915629d9a98f52fb266f82274785bb49c6.tar.gz
libnm: refactor NMSettInfoProperty to save memory for simple properties
In total, we register 447 property informations. Out of these, 326 are plain, GObject property based without special implementations. The NMSettInfoProperty had all function pointers directly embedded, currently this amounts to 5 function pointers and the "dbus_type" field. That means, at runtime we have 326 times trivial implementations with waste 326*6*8 bytes of NULL pointers. We can compact these by moving them to a separate structure. Before: 447 * 5 function pointers 447 * "dbus_type" pointer = 2682 pointers After: 447 * 1 pointers (for NMSettInfoProperty.property_type) 89 * 6 pointers (for the distinct NMSettInfoPropertType data) = 981 pointers So, in total this saves 13608 byes of runtime memory (on 64 bit arch). The 89 NMSettInfoPropertType instances are the remaining distinct instances. Note that every NMSettInfoProperty has a "property_type" pointer, but most of them are shared. That is because the underlying type and the operations are the same. Also nice is that the NMSettInfoPropertType are actually constant, static fields and initialized very early. This change also makes sense form a design point of view. Previously, NMSettInfoProperty contained both per-property data (the "name") but also the behavior. Now, the "behavioral" part is moved to a separate structure (where it is also shared). That means, the parts that are concerned with the type of the property (the behavior) are separate from the actual data of the property.
Diffstat (limited to 'libnm-core/nm-setting-vpn.c')
-rw-r--r--libnm-core/nm-setting-vpn.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libnm-core/nm-setting-vpn.c b/libnm-core/nm-setting-vpn.c
index a337d857cf..da1b8e2cad 100644
--- a/libnm-core/nm-setting-vpn.c
+++ b/libnm-core/nm-setting-vpn.c
@@ -1132,7 +1132,7 @@ nm_setting_vpn_class_init (NMSettingVpnClass *klass)
_properties_override_add_transform (properties_override,
obj_properties[PROP_DATA],
- G_VARIANT_TYPE ("a{ss}"),
+ NM_G_VARIANT_TYPE ("a{ss}"),
_nm_utils_strdict_to_dbus,
_nm_utils_strdict_from_dbus);
@@ -1159,7 +1159,7 @@ nm_setting_vpn_class_init (NMSettingVpnClass *klass)
_properties_override_add_override (properties_override,
obj_properties[PROP_SECRETS],
- G_VARIANT_TYPE ("a{ss}"),
+ NM_G_VARIANT_TYPE ("a{ss}"),
vpn_secrets_to_dbus,
vpn_secrets_from_dbus,
NULL);