[perf] DrawInputField recomputes caret X via full-prefix walk every frame (InputField.cpp) #128
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics#128
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-InputField.cpp:151-153Severity: low · Effort: moderate · Category: cpu
Problem
For a focused, caret-visible field,
DrawInputFieldwalks the whole cursor prefix viaGetLineWidthevery frame even though onlycaretVisible(the blink) changes. Cost is bounded —AdvanceUnitsis memoized (no stbtt), only the single focused field hits it, and the prefix is short for typical fields.Fix
Memoize
caretXkeyed on(value, cursorPos, fontSize). Needs a mutable/external cache sinceDrawInputFieldtakesconst InputField&.