Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all: avoid using too many packages.Need bits
go/packages.LoadMode exists so that it only asks `go list` for the information you need, and no more. Some of those bits are actually pretty expensive to use. For instance, the Syntax ones will use go/parser to load go/ast files, and NeedDeps will mean loading info for all dependencies recursively. We really don't need everything; in fact, our needs are rather simple. Reduce the LoadMode sets we use, driven by skimming the code and re-running the tests and generation steps to ensure nothing is broken. As a very coarse benchmark, the tests for the two packages get faster on average, running three times before and after: cmd/cue/cmd goes from ~3.2s to ~2.8s encoding/gocode goes from ~1.1s to ~0.2s Overall, `cue get go` and `gocode.Generate` should be slightly faster. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I08cd45b5ecd9bdd9ce84e2ceadc70880f82293c2 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/538063 Unity-Result: CUEcueckoo <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Roger Peppe <[email protected]>
- Loading branch information