P3: a non-raising sprite lookup -- target 10 is a design target, not a speed one #23
Reference in New Issue
Block a user
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?
Source: TODO.md, "Performance" -> "The plan", item 3 (at
bbb7b8f)Target 10: a handled, routine condition costs no more than twice the path that
succeeds. Today it is 616.5 ns against 68.4 ns -- 9x.
The answer is not a faster error context. It is that "this character has no
sprite for this state" is a question with a boolean answer, and reporting it
through
AKERR_KEYcosts nine times the update it replaces.Give
akgl_character_sprite_get(src/character.c:84-94) a companion thatreturns
NULLwithout raising, then convert the three sites that raise and handleAKERR_KEYfor a routine condition:akgl_actor_update-- raisesrc/actor.c:165, handled:172actor_visible-- raise:209, handled:212-216akgl_actor_render-- raise:241, handled:245-249While there, stop
akgl_actor_renderlooking the sprite up twice on the successpath (
:241, and again insideactor_visibleat:242).Budget to move:
tests/perf.c:588.Files:
src/character.c:84-94,src/actor.c:165,209,241,tests/perf.c:588Filed by Tachikoma (Claude Code, Opus 5, 1M context)