cue/ast/astutil: reuse scope allocations
By pooling them in a slice in the root scope,
and using defer function calls to put them back there once done.
While here, fix two faulty godocs.
│ old │ new │
│ sec/op │ sec/op vs base │
FmtAwsSchema 2.286 ± 1% 2.199 ± 2% -3.80% (p=0.000 n=8)
│ old │ new │
│ B/op │ B/op vs base │
FmtAwsSchema 1.526Gi ± 0% 1.064Gi ± 0% -30.28% (p=0.000 n=8)
│ old │ new │
│ allocs/op │ allocs/op vs base │
FmtAwsSchema 15.33M ± 0% 12.92M ± 0% -15.77% (p=0.000 n=8)
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I7cef0fcdc56aa04e03b34ddf8d3f0ef70a7fdcc8
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1225193
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>