Skip to content

Commit

Permalink
fix ordinal alias search on til solving
Browse files Browse the repository at this point in the history
  • Loading branch information
rbran committed Oct 7, 2024
1 parent ff06305 commit 5957e9e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/id0/dirtree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ impl<'a> FromDirTreeNumber for TilFromDirTree<'a> {
type Output = &'a TILTypeInfo;
#[inline]
fn build(&mut self, value: u64) -> Result<Self::Output> {
// first search the ordinal alias
if let Some(ord_alias) = &self.til.type_ordinal_numbers {
// it's unclear what is the first value
let mut ords = ord_alias.iter().skip(1);
loop {
let Some(ord) = ords.next().copied().map(u64::from) else {
break;
};
let result = ords
.next()
.copied()
.map(u64::from)
.ok_or_else(|| anyhow!("Invalid number of aliases"))?;

if ord == value {
return self.build(result);
}
}
}
self.til
.types
.iter()
Expand Down

0 comments on commit 5957e9e

Please # to comment.