cmd/compile/internal/types: simplify iterating all parameters

The types.RecvsParamsResults, etc. helpers existed to make it "easier"
to iterate over all parameters, or recvs+params, or params+results;
but they end up still being quite clumsy to use due to the design goal
of not allocating temporary slices.

Now that recvs+params+results are stored in a single consecutive slice
anyway, we can just return different subslices and simplify the loops.

Change-Id: I84791b80dc099dfbfbbe6eddbc006135528c23b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/521375
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Matthew Dempsky 2023-08-20 15:07:00 -07:00 committed by Gopher Robot
parent 4b9a70a3b7
commit 3d15bfaa3e
6 changed files with 56 additions and 66 deletions

View file

@ -270,12 +270,10 @@ func createDwarfVars(fnsym *obj.LSym, complexOK bool, fn *ir.Func, apDecls []*ir
func sortDeclsAndVars(fn *ir.Func, decls []*ir.Name, vars []*dwarf.Var) {
paramOrder := make(map[*ir.Name]int)
idx := 1
for _, selfn := range &types.RecvsParamsResults {
for _, f := range selfn(fn.Type()) {
if n, ok := f.Nname.(*ir.Name); ok {
paramOrder[n] = idx
idx++
}
for _, f := range fn.Type().RecvParamsResults() {
if n, ok := f.Nname.(*ir.Name); ok {
paramOrder[n] = idx
idx++
}
}
sort.Stable(varsAndDecls{decls, vars, paramOrder})