]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-netlink: pahole optimization of sd_netlink_slot
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 9 Feb 2021 18:51:50 +0000 (19:51 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 10 Feb 2021 13:43:10 +0000 (14:43 +0100)
By rearranging the fields, we can avoid one of the holes (on amd64).
By adding more space for .type, -EINVAL can be used as a value later on.
The structure is reduced from 96 to 88 bytes (on amd64).

Text size is also smaller:
-rwxrwxr-x 1 zbyszek zbyszek 4109832 Feb  9 19:50 build/libsystemd.so.0.30.0
-rwxrwxr-x 1 zbyszek zbyszek 4109792 Feb  9 19:51 build/libsystemd.so.0.30.0

src/libsystemd/sd-netlink/netlink-internal.h

index efd0cf93358456a279dac2e154747d7e665236f2..9159f94dd9ab4809f5565a3cb5972cc1e6f85250 100644 (file)
@@ -38,12 +38,12 @@ typedef enum NetlinkSlotType {
 
 struct sd_netlink_slot {
         unsigned n_ref;
+        NetlinkSlotType type:8;
+        bool floating;
         sd_netlink *netlink;
         void *userdata;
         sd_netlink_destroy_t destroy_callback;
-        NetlinkSlotType type:2;
 
-        bool floating:1;
         char *description;
 
         LIST_FIELDS(sd_netlink_slot, slots);