Tweaked lfsr_attr_isnoop to assert on delta != 0
Now it is fit for purpose and can replace the explicit tag comparison +
assert in lfsr_rbyd_appendattr. Previously we had to check if delta==0,
but now we just assert that delta!=0 is invalid for noops.
Unfortunately this added a couple bytes of code. The disassembly for
lfsr_rbyd_appendattr is all shuffled up, so I guess this is just
compiler noise. At least it's better than an explicit delta check:
code stack
before: 33820 2632
check delta: 33832 (+0.0%) 2632 (+0.0%)
assert delta: 33828 (+0.0%) 2632 (+0.0%)
This commit is contained in:
@@ -1574,7 +1574,9 @@ static int lfsr_bd_progcat(lfs_t *lfs,
|
||||
|
||||
// other attr helpers
|
||||
static inline bool lfsr_attr_isnoop(lfsr_attr_t attr) {
|
||||
return !attr.tag && attr.delta == 0;
|
||||
// noop attrs must have zero delta
|
||||
LFS_ASSERT(attr.tag || attr.delta == 0);
|
||||
return !attr.tag;
|
||||
}
|
||||
|
||||
static inline bool lfsr_attr_isinsert(lfsr_attr_t attr) {
|
||||
@@ -2855,8 +2857,7 @@ static int lfsr_rbyd_appendattr(lfs_t *lfs, lfsr_rbyd_t *rbyd,
|
||||
LFS_ASSERT(attr.delta >= -(lfsr_srid_t)rbyd->weight);
|
||||
|
||||
// ignore noops
|
||||
if (!attr.tag) {
|
||||
LFS_ASSERT(attr.delta == 0);
|
||||
if (lfsr_attr_isnoop(attr)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user