[perf][LOW] Ensure()+Lookup() do two hash-map probes per glyph #53
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics#53
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Subsystem: Font / text shaping
Location:
implementations/Crafter.Graphics-UI-Shared.cpp:61-82Impact: LOW · Effort: Small
Problem
Per codepoint,
Ensuredoescache_.contains(key)thenLookupimmediately doescache_.find(key)— two independent hashes + node-chases of the same key, every glyph every frame, even in steady state.Proposed fix
EnsureAndGetreturningconst Glyph*(onefind, insert-on-miss, return&it->second).Correctness caveat
EnsureAndGetmust returnnullptronShelfPlacefailure to preserve the existingif (g==nullptr) continue;behavior. Largely subsumed by the shaped-run cache issue.