New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Last state iterator #109
Last state iterator #109
Conversation
And remove recursive calls.
Thank you! This change seems to fix the bugs I encountered yesterday with iteration. |
Nice, to hear. Currently cleaning this branch. |
This PR should be reviewable. @i1i1 with this pr, I did change the way the iterator behave when switching direction. |
src/btree/iter.rs
Outdated
let is_leaf = btree.depth as usize + 1 == self.state.len(); | ||
if let Some(state) = self.state.last_mut() { | ||
let next = match (direction, &state.0) { | ||
(_, LastIndex::Descend(_)) => unreachable!("exit function clean it"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(_, LastIndex::Descend(_)) => unreachable!("exit function clean it"), | |
(_, LastIndex::Descend(_)) => unreachable!("Last state should be clean after calling self.exit"), |
Is it always cleaned by self.exit
though? From what I can follow, sometimes self.enter
is called instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, and enter will put a non descend too, this assumption is a bit of a headache, I propose to replace it with 2b95bce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel knowledgeable enough to properly review this PR.
I just have some code style suggestions (but feel free to ignore it).
I have also fuzzed the code and it seems to work \o/.
they are very welcome, will fix in a bit. |
@i1i1 if you got time to triple check this PR, review is very welcome (even if things get merge already I will create new PR). |
This is a small refactor of iterator logic when switching backward/forward.
Mainly removea bit of redundant code and makes that we do not return same value when changing iteration direction.
Currently draft as I need to reread it and clippy it, but @Tpt it may be interesting to run your fuzzer on this branch.