Skip to content

perf: hand glyphon the text areas as an iterator, not a Vec - #26

Merged
tkc merged 1 commit into
mainfrom
pass-areas-as-iterator
Sep 10, 2026
Merged

perf: hand glyphon the text areas as an iterator, not a Vec#26
tkc merged 1 commit into
mainfrom
pass-areas-as-iterator

Conversation

@tkc

@tkc tkc commented Sep 10, 2026

Copy link
Copy Markdown
Owner

prepare takes impl IntoIterator<Item = TextArea>, but the chained iterator was being collected into a Vec first: 7,661 areas of ~64 bytes on a full screen, so about 0.5 MB allocated and dropped every frame. Passing the iterator straight through is a one-line change.

--bench, three runs each side:

size prepare before prepare after
1280x800 (7,661 cells) 0.54 / 0.54 / 0.56 ms 0.45 / 0.47 / 0.48 ms
1920x1200 (17,150 cells) 1.19 / 1.20 / 1.23 ms 1.02 / 1.03 / 1.05 ms

13–16% off prepare. This is the follow-up to #25's finding that one area per cell is the right shape after all — so the remaining win was in how those areas are handed over, not in how many there are.

Documented in docs/performance.md 7.14 and in the techniques catalogue.

Test

cargo test — 202 pass. cargo clippy --all-targets -- -D warnings and cargo fmt --check — clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GvMacYD6T9EoWqc7C247Hr

prepare() takes impl IntoIterator<Item = TextArea>, but the chained
iterator was collected into a Vec first: 7,661 areas of about 64 bytes on
a full screen, allocated and dropped every frame.

--bench, three runs each side: prepare 0.54-0.56ms -> 0.45-0.48ms at
1280x800, and 1.19-1.23ms -> 1.02-1.05ms at 1920x1200. 13-16% off.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GvMacYD6T9EoWqc7C247Hr
@tkc
tkc merged commit 7585a34 into main Sep 10, 2026
1 check passed
@tkc
tkc deleted the pass-areas-as-iterator branch September 10, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant