mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
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 <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
9dce58d30d
commit
e92853523d
|
@ -306,20 +306,20 @@ func nodl(pos src.XPos, op Op, nleft, nright *Node) *Node {
|
||||||
switch op {
|
switch op {
|
||||||
case OCLOSURE, ODCLFUNC:
|
case OCLOSURE, ODCLFUNC:
|
||||||
var x struct {
|
var x struct {
|
||||||
Node
|
n Node
|
||||||
Func
|
f Func
|
||||||
}
|
}
|
||||||
n = &x.Node
|
n = &x.n
|
||||||
n.Func = &x.Func
|
n.Func = &x.f
|
||||||
case ONAME:
|
case ONAME:
|
||||||
Fatalf("use newname instead")
|
Fatalf("use newname instead")
|
||||||
case OLABEL, OPACK:
|
case OLABEL, OPACK:
|
||||||
var x struct {
|
var x struct {
|
||||||
Node
|
n Node
|
||||||
Name
|
m Name
|
||||||
}
|
}
|
||||||
n = &x.Node
|
n = &x.n
|
||||||
n.Name = &x.Name
|
n.Name = &x.m
|
||||||
default:
|
default:
|
||||||
n = new(Node)
|
n = new(Node)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue