[perf] ShapeText heap-allocates the cache-key std::string on every call, including hits (UI-Shared.cpp) #122
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics#122
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?
Found by an adversarially-verified performance audit (confirmed real after a skeptic pass).
Location:
implementations/Crafter.Graphics-UI-Shared.cpp:78-79Severity: medium · Effort: moderate · Category: allocation
Problem
ShapeTextbuildsShapedRunKey{..., std::string(utf8)}beforefind()unconditionally, including on cache hits, on the per-frameonBuildpath. N labels = N string copies + hashes (+ frees for non-SSO strings) per frame, partially defeating the run cache.Fix
is_transparenttransparent hash + equality onshapedRuns_; probe with a view-key{const Font*, float, array<float,4>, string_view}and materialize the owningstd::stringonly on miss foremplace.