Repository navigation
perf: a menu's step and a press draw only the controls they change - #26
Merged
Merged
Conversation
`MenuButton` read the whole layer to know whether its menu was open, and `Modal` and `PhotoViewer` read it for the page's size: every step of the pointer over an open menu, and every toast, drew each of them again. Each focusable control read which control has the keys, so a press anywhere drew every control on the page. All four are memos now, which tell only the controls whose answer changed. Found while timing Diaryx's entry menus on a library of 2,000 pages, where a search draws a "…" for every hit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P3EBi1gz7evG9fSSg22tcL
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.
MenuButtonread the whole layer to know whether its menu was open, andModalandPhotoViewerread it for the page's size: every step of the pointer over an open menu, and every toast, drew each of them again. Each focusable control read which control has the keys (Unit::focused), so a press anywhere drew every control on the page.All four are memos now (
use_memo), which tell only the controls whose answer changed:Focusholds aMemo<bool>of whether it has the keys;is_focusedandringread it.MenuButton'saria-expandedreads a memo ofmenu_owner() == Some(id).ModalandPhotoViewerread a memo ofviewport.Found while timing Diaryx's entry menus on a library of 2,000 pages, where a search draws a "…" for every hit (diaryx-org/diaryx, same branch).
Checks
cargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warningscargo clippy -p unit-gallery --target wasm32-unknown-unknown --no-default-features --features web -- -D warningscargo test --workspace: all pass, including the Blitz and audit suitesRUSTDOCFLAGS='-D warnings' cargo doc -p unit --no-depsRun with cargo; corgi isn't installed in this environment.
Generated by Claude Code