gui: the core's budget counts code, not comments (#5918)

TestCoreScriptBudget counted every byte of the core scripts, so a change
that reached the cap was paid for by cutting comments that said why the
code is as it is (five times on 11-10 alone, and 40-odd "comments cut"
in the budget's own history). Main was red on it again from 16ed1a952:
1,534,484 at 8016205e3 against a cap of 1,533,802.

The test now counts code only: blank lines, lines that are only a //
comment and /* */ blocks that start a line aren't counted (codeBytes).
The caps are set once to that measure at 8016205e3: app.js 1,086,267
(1,080,614 plus the 5,653 of room it had), the core 1,263,333 with no
room. That takes in the 682 bytes the old measure was over; the step
over was features measured with their comments. From now on cutting a
comment pays for nothing; moving a page out still does. The ~20KB of
history in the constants' comments is replaced by a pointer to
`git log -L` of the file.

Run on mote (Go 1.26.8), at this tree on origin/main 8016205e3:
- go test -tags nogui -count=1 -run TestCoreScriptBudget ./internal/gui: ok
- broken by hand: 20KB of // and a 5KB /* */ block appended to app.js
  stay ok; one 20-byte line of code on top fails "over their budget";
  restored.
- go test -tags nogui -count=1 ./internal/gui (the whole package): ok, 83s.
- gofmt -l internal/gui: clean.

Not tried: the GUI suite (no script changed).
This commit is contained in:
yetone
2026-11-11 21:33:54 +08:00
parent 7a1414f0cf
commit 6cc182339a
File diff suppressed because one or more lines are too long