Dropped LFSR_CAT_CAT

With LFSR_CAT_DATAS for explicit arrays of datas, and this biggest use
of concatenated data being a rather explicit construction in
lfsr_file_carve, I don't think we really need LFSR_CAT_CAT.

The only non-hacky use was to define LFSR_CAT_NAME. But we know names
always use exactly 2 datas, so this might as well use LFSR_CAT_DATAS.

I am going to use this soapbox to complain a bit about compound struct
literals. Why do we need an array declaration to elevate temporary
structs to automatic storage duration? I wish you could init a compound
literal with the struct itself...

  ✗ &f()
  ✓ &(uint32_t){f()}
  ✓ (uint32_t[]){f()}

  ✗ &f()
  ✗ &(lfsr_data_t){f()}   :(
  ✓ (lfsr_data_t[]){f()}

Some hacky compound array literals were needed to replace the hacky
LFSR_CAT_CATs in lfsr_file_carve for this reason, but I guess it's a
hack for a hack so...

Code unchanged:

           code          stack
  before: 33728           2776
  after:  33728 (+0.0%)   2776 (+0.0%)
This commit is contained in:
Christopher Haster
2024-05-06 00:35:55 -05:00
parent 77bfcb69ad
commit ca2d0b980c
+9 -12
View File
@@ -1446,11 +1446,6 @@ typedef struct lfsr_cat {
#define LFSR_CAT_DATAS(_datas, _count) \
lfsr_cat_fromdatas(_datas, _count)
#define LFSR_CAT_CAT(...) \
lfsr_cat_fromdatas( \
(const lfsr_data_t[]){__VA_ARGS__}, \
sizeof((const lfsr_data_t[]){__VA_ARGS__}) / sizeof(lfsr_data_t))
// cat helpers
static inline bool lfsr_cat_isbuf(lfsr_cat_t cat) {
return !(cat.u.size & LFSR_CAT_ISCAT);
@@ -1516,9 +1511,11 @@ static inline lfsr_cat_t lfsr_cat_fromlleb128(uint32_t word,
}
#define LFSR_CAT_NAME(_did, _name, _name_size) \
LFSR_CAT_CAT( \
lfsr_cat_data(LFSR_CAT_LEB128(_did)), \
LFSR_DATA_BUF(_name, _name_size))
LFSR_CAT_DATAS( \
((const lfsr_data_t[2]){ \
lfsr_cat_data(LFSR_CAT_LEB128(_did)), \
LFSR_DATA_BUF(_name, _name_size)}), \
2)
// cat <-> bd interactions
//
@@ -10393,9 +10390,9 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file,
LFSR_ATTR(
LFSR_TAG_GROW | LFSR_TAG_SUB | LFSR_TAG_DATA,
-(weight_ - lfs->cfg->fragment_size),
LFSR_CAT_CAT(
LFSR_CAT_DATA((lfsr_data_t[]){
lfsr_data_truncate(left_slice_,
lfs->cfg->fragment_size))),
lfs->cfg->fragment_size)})),
LFSR_ATTR(
LFSR_TAG_BLOCK, +(weight_ - lfs->cfg->fragment_size),
LFSR_CAT_BPTR(&bptr_))));
@@ -10426,9 +10423,9 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file,
LFSR_ATTR(
LFSR_TAG_DATA,
+(weight_ - lfsr_data_size(bptr_.data)),
LFSR_CAT_CAT(
LFSR_CAT_DATA((lfsr_data_t[]){
lfsr_data_fruncate(right_slice_,
lfs->cfg->fragment_size)))));
lfs->cfg->fragment_size)}))));
if (err) {
return err;
}