Replaced large struct macros with init functions

While they are a bit more annoying to call, init functions give the
compiler a chance to deduplicate common struct initialization logic. So
we should probably prefer init functions for any structs larger than a
couple words.

The cost of each init is small, but it really adds up!

           code          stack          ctx
  before: 38036           2608          752
  after:  37844 (-0.5%)   2608 (+0.0%)  752 (+0.0%)
This commit is contained in:
Christopher Haster
2025-01-05 23:57:48 -06:00
parent 50933929a4
commit eadc207dc5
6 changed files with 220 additions and 131 deletions
+6 -3
View File
@@ -61,7 +61,8 @@ code = '''
lfs_alloc_ckpoint(&lfs);
// create a btree
lfsr_btree_t btree = LFSR_BTREE_NULL();
lfsr_btree_t btree;
lfsr_btree_init(&btree);
// set up a simulation to compare against
char *sim = malloc(N);
@@ -1835,7 +1836,8 @@ code = '''
lfs_alloc_ckpoint(&lfs);
// create a btree
lfsr_btree_t btree = LFSR_BTREE_NULL();
lfsr_btree_t btree;
lfsr_btree_init(&btree);
// set up a simulation to compare against
char *sim = malloc(N);
@@ -3609,7 +3611,8 @@ code = '''
lfs_alloc_ckpoint(&lfs);
// create a btree
lfsr_btree_t btree = LFSR_BTREE_NULL();
lfsr_btree_t btree;
lfsr_btree_init(&btree);
// set up a simulation to compare against
char *sim = malloc(N);