perf(atlas_viewer): cache sorted sprite list (#156)#185
Conversation
… per frame (#156) `renderSpriteList` was rebuilding + sorting an ArrayList of frame keys every frame the Atlas Viewer was open — N allocs + an O(N log N) sort per frame for atlases with hundreds of entries (flying-platform's `characters.json` has 100+). `Atlas.sorted_frame_keys` (added via #180) already holds the alpha- ordered key view, built once at load. Iterate that directly. Drive-by: `renderSpriteList`'s `app` parameter was only there for the allocator; with the per-frame ArrayList gone the parameter is unused, so it's dropped from both the signature and the call site. The now-orphaned `lessName` comparator is removed.
PR SummaryLow Risk Overview
Reviewed by Cursor Bugbot for commit 5d4aaab. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Code Review
This pull request simplifies the renderSpriteList function in src/modules/atlas_viewer.zig by utilizing a pre-sorted list of frame keys (cur.sorted_frame_keys) instead of dynamically allocating, collecting, and sorting the frame names on every render call. This removes the dependency on the App allocator and the helper function lessName. There are no review comments, so no additional feedback is provided.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR optimizes the Atlas Viewer’s per-frame sprite list rendering by eliminating a rebuild+sort of frame names each frame and instead iterating the atlas’s precomputed sorted_frame_keys, removing per-frame allocations and redundant O(N log N) work.
Changes:
- Switch sprite list rendering to iterate
Atlas.sorted_frame_keysdirectly (pre-sorted at atlas load time). - Remove the now-unneeded per-frame
ArrayListconstruction/sort and drop the unusedappparameter fromrenderSpriteList. - Delete the orphaned
lessNamecomparator.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Closes one of the #156 nits —
atlas_viewer.zigsprite-list per-frame sort.renderSpriteListwas rebuilding + sorting an ArrayList of frame keys every frame the Atlas Viewer was open — N allocs + O(N log N) per frame for atlases with hundreds of entries (flying-platform'scharacters.jsonhas 100+).Atlas.sorted_frame_keys(added via #180) already carries the alpha-ordered view, built once at load. Iterate that directly. Net change: +3 / −16, zero per-frame allocations on this render path.Drive-by:
renderSpriteList'sappparameter was only there for the allocator; with the per-frame ArrayList gone it's unused, so it's dropped from the signature + call site.lessNamecomparator is removed.Test plan