libopkg: tighten length of fields in struct abstract_pkg
authorDaniel Golle <daniel@makrotopia.org>
Mon, 2 Nov 2020 16:43:02 +0000 (16:43 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 2 Nov 2020 20:21:01 +0000 (20:21 +0000)
Should reduce the size of that struct and hence memory consumption
during dependency resolution (48 bytes vs. 56 bytes on 64-bit).

Suggested-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
libopkg/pkg.h

index 600fc9eaa25ca362d67c0ac108686b624de9f953..4ce13ea69d131ede6423a6f8bd1d4f45e94e4c71 100644 (file)
@@ -105,17 +105,17 @@ enum pkg_fields {
 
 struct abstract_pkg {
        char *name;
-       int dependencies_checked;
        pkg_vec_t *pkgs;
-       pkg_state_status_t state_status;
-       pkg_state_flag_t state_flag;
+       int dependencies_checked:1;
+       pkg_state_status_t state_status:4;
+       pkg_state_flag_t state_flag:11;
 
        /* XXX: This should be abstract_pkg_vec_t for consistency. */
        struct abstract_pkg **depended_upon_by;
 
        abstract_pkg_vec_t *provided_by;
        abstract_pkg_vec_t *replaced_by;
-};
+} __attribute__((__packed__)) ;
 
 #include "pkg_depends.h"