Files
magpie/internal
yetone d6f59f9fd0 sessions: a Claude message is looked up without making its key again
Every line of a Claude reply looked its message up by "message:"+id, a
new string each time, though only the line that adds the message keeps
it. The key is now built in a stack buffer for the lookup, made a
string only when a message is added, and a second branch of a message
takes the key its first one made.

Measured on mote, cold start over a copy of real Claude and Codex
histories (acold.sh, 120s), against v0.1.3152 built at the same base:
  message() 157MB -> 142MB, footprint peak 186MB -> 180MB,
  heap peak 169MB -> 163MB, GCs 129 -> 122; total allocated the same
  within noise (3.67GB vs 3.70GB). Most replies are one line, so most
  lookups add the message.

Test: TestClaudeMessageLookupAllocations: a message's later line makes
0 allocations; a second branch shares the first's key string; a
request-only message is keyed by its request. Red by hand with the old
lookup ("made 1 allocations, want 0").

Run on mote at the pushed tree: go vet and go test ./internal/sessions.
Not run: the full suite (last run at v0.1.3152's change, 85 packages
ok, reds only #3949 and #5481).
2026-11-06 18:50:13 +08:00
..
…
…
…
…
…
…
…