tomlFileOf keeps a config's parse while the file is unchanged. Each key's
text, prefix and suffix were slices of the file's string, so the whole
file stayed alive beside the parse (1.5 MB of the owner's Codex
config.toml, ~11k project tables). The tables and names were also grown
by append and kept with their room. What is kept is now copied out:
text cloned, the prefixes and suffixes a config repeats on every line
(`trust_level = `, ` # …`) interned once through unique, and the tables,
each table's keys and the names held at their exact length.
Run on mote at this head:
- go test ./internal/edit: ok
- GOOS=darwin/linux/windows go vet ./internal/edit: ok
- gofmt -l: clean
- Broken by hand: without keptKeys on the tables,
TestTOMLFileKeepsNoFileText is red ("2996 keys' text is still a slice
of the file's"); with slices.Clone for the tables it was red on their
room (3000/3072).
- Real-account copy (~/r2278/acct), idle heap at 180s: edit.tomlFileOf
7.14 MB -> 2.97 MB; heap total 89.4 MB (102-103 MB the run before);
Footprint 151 MB.