From e92853523d11d1e50d89a3c017c5d902aed0596a Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 17 Apr 2019 11:37:54 -0700 Subject: [PATCH] cmd/compile: use named fields in nodl We use a struct to allocate two structs simultaneously. Because we embed structs rather than using named fields, the compiler generates forwarding method stubs for the anonymous type. In theory, the compiler could detect that these stubs are unnecessary: The value in question has a very limited scope, the methods are not called, and there are operations where an interface would need to be satisfied. This compiler optimization is unlikely to happen, though; the ROI is likely to be low. Instead, just give the fields names. Cuts 64k off the cmd/compile binary. Change-Id: Id10ec69c23cd2dd33306f4c1bc75724e3c571b56 Reviewed-on: https://go-review.googlesource.com/c/go/+/172579 Run-TryBot: Josh Bleecher Snyder Reviewed-by: Matthew Dempsky TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/subr.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go index 156e3c2c94..5e74bee031 100644 --- a/src/cmd/compile/internal/gc/subr.go +++ b/src/cmd/compile/internal/gc/subr.go @@ -306,20 +306,20 @@ func nodl(pos src.XPos, op Op, nleft, nright *Node) *Node { switch op { case OCLOSURE, ODCLFUNC: var x struct { - Node - Func + n Node + f Func } - n = &x.Node - n.Func = &x.Func + n = &x.n + n.Func = &x.f case ONAME: Fatalf("use newname instead") case OLABEL, OPACK: var x struct { - Node - Name + n Node + m Name } - n = &x.Node - n.Name = &x.Name + n = &x.n + n.Name = &x.m default: n = new(Node) } -- 2.50.0