builders: filter test sources in place (#4646)
Large compilepkg and nogo actions can run test filtering after
readFileInfo has attached AST, import, and embed metadata to every Go
source. This matters because each discarded fileInfo may retain parser
state for a source file.
The old only and exclude modes allocated a second fileInfo slice. That
increased short-lived memory use and kept discarded metadata reachable
longer than needed.
Compact the Go source slice in place for test filtering and zero the
discarded tail. This preserves order and the existing off, only, and
exclude behavior while reducing allocation pressure in the builders
path.
Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
2 files changed