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:
@@ -2235,16 +2235,16 @@ static int lfsr_rbyd_lookupnext(lfs_t *lfs, const lfsr_rbyd_t *rbyd,
|
|||||||
// unreachable tags has a hole here
|
// unreachable tags has a hole here
|
||||||
tag = lfs_max16(tag, 0x1);
|
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
|
// keep track of bounds as we descend down the tree
|
||||||
lfs_size_t branch = rbyd->trunk;
|
lfs_size_t branch = rbyd->trunk;
|
||||||
lfsr_srid_t lower = 0;
|
lfsr_srid_t lower = 0;
|
||||||
lfsr_srid_t upper = rbyd->weight;
|
lfsr_srid_t upper = rbyd->weight;
|
||||||
|
|
||||||
// no trunk yet?
|
|
||||||
if (!branch) {
|
|
||||||
return LFS_ERR_NOENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
// descend down tree
|
// descend down tree
|
||||||
while (true) {
|
while (true) {
|
||||||
lfsr_tag_t alt;
|
lfsr_tag_t alt;
|
||||||
|
|||||||
Reference in New Issue
Block a user