Repository navigation
Conversation
val_at went through ReadZipperCore::get_val_at, which reaches the focus via the node below it on the stack. A secondary factor's root is pushed onto the stack without being that node's child, so with the focus on a joint or in the first node of a secondary factor it panicked (focus_parent unwrap) or looked in an unrelated node, and a path that crossed a joint was never followed into the next factor. Walk the trie nodes from the focus instead, without moving or copying the core. Where the walk stops at a leaf it reached by at least one step, it enters the next factor's root, as descend_to_existing does, so val_at(p) is descend_to(p) then val(). A value found inside the focus's factor returns straight away.
Extract walk_node_val_at / node_val_at in src/trie_node.rs to walk a non-empty path directly from (TaggedNodeRef, node_key) without going through focus_parent(), throwaway TrieRefBorrowed construction, or lifetime transmutes. - ReadZipperCore::get_val_at walks from *self.focus_node directly, fixing the root cause of the focus_parent() panic and removing the transmute and allocator clone. - ProductZipper::val_at loops over factors via walk_node_val_at::<true>, replacing its inline node-walking loop. - WriteZipperCore::val_at, TrieRefBorrowed::get_val_at, TrieRefOwned::val_at, and PathMap::val_at all share node_val_at.
imlvts
marked this pull request as ready for review
November 30, 2026 08:20
…h across joints Both asked only the zipper of the factor whose value the focus shows. So val_at / get_val_at answered None for any path that crosses a factor joint. At a joint itself they asked the earlier factor's leaf, not the factor entered there. Both now replay their own descend_to on read zippers forked from the factors, entering the next factor wherever the walk stands on a leaf. That includes the last step of descend_to, which enters at most one more factor and takes the rest of the path there. A value inside the focus's factor returns straight away, so lookups that stay inside it cost the same as before. ProductZipperG reads the value from its own factor zipper. Its val_at and get_val_at now require ZipperForking of the factors. DependentProductZipperG has its later factors made by the enroll function, so the walk calls it on a copy of the payload, which requires C: Clone. Such a factor zipper is dropped after the walk, so val_at needs factors whose values outlive them: val_at now has get_val_at's bounds (ZipperReadOnlyValues<'trie>, plus ZipperForking and C: Clone). A DependentProductZipperG over owned factors, such as the ExprFactor test enum, no longer has val_at. ExprFactor's PolyZipperExplicit list drops ZipperValuesAt, and its val_at test block goes. Tests compare val_at and get_val_at with descend_to then val/get_val, at and across joints, with long keys, with fixed factors, and with enroll functions that depend on the path and the payload.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This also refactors and speeds up a bunch of things (
walk_node_val_at).Perhaps it belongs as a method on the node?
val_at went through ReadZipperCore::get_val_at, which reaches the focus via the node below it on the stack. A secondary factor's root is pushed onto the stack without being that node's child, so with the focus on a joint or in the first node of a secondary factor it panicked (focus_parent unwrap) or looked in an unrelated node, and a path that crossed a joint was never followed into the next factor.
Walk the trie nodes from the focus instead, without moving or copying the core. Where the walk stops at a leaf it reached by at least one step, it enters the next factor's root, as descend_to_existing does, so val_at(p) is descend_to(p) then val(). A value found inside the focus's factor returns straight away.