Avoid touching disk when out-of-bounds in lfsr_rbyd_lookupnext

We really shouldn't go to disk in cases like these, it's not worth the
code tradeoff. This led to concious decisions to avoid out-of-bound
lookups in higher-layers, which sort of defeats any benefit of this
potential optimization.

            code          stack
  before:  33948           2944
  after:   33956 (+0.0%)   2944 (+0.0%)
This commit is contained in:
Christopher Haster
2024-01-19 15:33:41 -06:00
parent 9adb22eee0
commit fdfa7b5908
+5 -5
View File
@@ -2235,16 +2235,16 @@ static int lfsr_rbyd_lookupnext(lfs_t *lfs, const lfsr_rbyd_t *rbyd,
// unreachable tags has a hole here
tag = lfs_max16(tag, 0x1);
// out of bounds? no trunk yet?
if (rid >= rbyd->weight || !rbyd->trunk) {
return LFS_ERR_NOENT;
}
// keep track of bounds as we descend down the tree
lfs_size_t branch = rbyd->trunk;
lfsr_srid_t lower = 0;
lfsr_srid_t upper = rbyd->weight;
// no trunk yet?
if (!branch) {
return LFS_ERR_NOENT;
}
// descend down tree
while (true) {
lfsr_tag_t alt;