Repository navigation
Route NestedTree's collapse calls through one loop - #110
Merged
Merged
Conversation
collapsible, is_collapsed, toggle_collapsed, collapse and expand each looked up the tree managing the position and checked that it can collapse; _on_subtree now does that once, replacing _get_subtree_for. It walks down through NestedTrees nested directly in each other in a loop, where the methods used to recurse once per level. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
NestedTree.collapsible,is_collapsed,toggle_collapsed,collapseandexpandeach looked up the tree managing the position and checked that it can collapse. The new private_on_subtreedoes that once and replaces_get_subtree_for; each method is one line. Found by an audit for over-engineering.When
NestedTrees are wrapped directly in each other, these methods used to call themselves once per level and failed at about a thousand levels._on_subtreewalks down to the managing tree in a loop, so there is no such limit now.test_collapse_deeply_nestedcollapses through 1100 levels; it fails onmain.Return values are unchanged:
collapsibleandis_collapseddefault toFalse, the other three returnNone. A seeded differential test over 30 random nested trees with all collapse calls gives identical results onmainand this branch.Review findings and resolution
review-correctness
NestedTree(method and helper), halving the depth that worked: fixed, by walking in a loop, which removes the recursion altogether; regression test added._get_subtree_foris removed: left; private and unused elsewhere.review-design
getattris slightly harder to grep than direct calls: left; a helper returning the tree would be the same size, and the reviewer did not require it.🤖 Generated with Claude Code