Dropped LFSR_DATA_* macros with implicit buffers

This was a disappointing failure of compount-literals.

These macros protect against mismatched buffer sizes, which is great for
preventing bugs caused by simple typos, but the overhead of compound-
literals requiring initialization make them simply unusable.

This commit leaves only a couple macros with implicit buffers:
LFSR_DATA_LEB128, and the LFSR_RAT_CAT/LFSR_RATS macros.

Even the tiny cleanup of the one remaining implicit-buffer macro still
in use, LFSR_DATA_GEOMETRY, saved some code:

           code          stack          ctx
  before: 38084           2608          752
  after:  38060 (-0.1%)   2608 (+0.0%)  752 (+0.0%)
This commit is contained in:
Christopher Haster
2025-01-05 00:54:07 -06:00
parent 1746819c7c
commit 80f4e0b825
3 changed files with 62 additions and 71 deletions
+12 -6
View File
@@ -908,12 +908,15 @@ code = '''
// note we're messing around with internals to do this! this
// is not a user API
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
uint8_t geometry_buf[LFSR_GEOMETRY_DSIZE];
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_RATS(
LFSR_RAT(
LFSR_TAG_GEOMETRY, 0,
LFSR_DATA_GEOMETRY((&(lfsr_geometry_t){
INC_BLOCK_SIZE,
BLOCK_COUNT}))))) => 0;
LFSR_DATA_GEOMETRY(
(&(lfsr_geometry_t){
INC_BLOCK_SIZE,
BLOCK_COUNT}),
geometry_buf)))) => 0;
lfsr_unmount(&lfs) => 0;
// mount should now fail
@@ -935,12 +938,15 @@ code = '''
// note we're messing around with internals to do this! this
// is not a user API
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
uint8_t geometry_buf[LFSR_GEOMETRY_DSIZE];
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_RATS(
LFSR_RAT(
LFSR_TAG_GEOMETRY, 0,
LFSR_DATA_GEOMETRY((&(lfsr_geometry_t){
BLOCK_SIZE,
INC_BLOCK_COUNT}))))) => 0;
LFSR_DATA_GEOMETRY(
(&(lfsr_geometry_t){
BLOCK_SIZE,
INC_BLOCK_COUNT}),
geometry_buf)))) => 0;
lfsr_unmount(&lfs) => 0;
// mount should now fail
+4 -1
View File
@@ -4323,10 +4323,13 @@ code = '''
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
lfs_alloc_ckpoint(&lfs);
uint8_t mptr_buf[LFSR_MPTR_DSIZE];
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_RATS(
LFSR_RAT(
LFSR_TAG_MROOT, 0,
LFSR_DATA_MPTR(LFSR_MPTR_MROOTANCHOR())))) => 0;
LFSR_DATA_MPTR(
LFSR_MPTR_MROOTANCHOR(),
mptr_buf)))) => 0;
// technically, cycle detection only needs to work when we're validating
lfsr_traversal_t t = LFSR_TRAVERSAL(