perf(text): fold Ensure+Lookup into FontAtlas::EnsureAndGet (#53) #84
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!84
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-53"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Per codepoint,
ShapeTextdidcache_.contains(key)(insideEnsure) immediately followed bycache_.find(key)(insideLookup) — two independent hashes + node-chases of the same key, every glyph every frame even in steady state.Fix
Add
FontAtlas::EnsureAndGetreturningconst Glyph*: a singlefind, insert-on-miss, returns&it->second. It returnsnullptronly onShelfPlacefailure, preserving the existingif (g==nullptr) continue;skip behavior. A glyph with no SDF coverage (e.g. space) still returns a valid pointer.Ensurenow delegates toEnsureAndGet.The call site in
ShapeTextruns on the shaped-run cache miss path (#52), so this trims work whenever a new run is shaped.Tests
crafter-build test— 4 passed, includingShapeTextCache.Resolves #53