mirror of
https://github.com/golang/go
synced 2024-11-20 00:44:45 -07:00
cmd/compile: convT2{I,E} don't handle direct interfaces
We now inline type to interface conversions when the type is pointer-shaped. No need to keep code to handle that in convT2{I,E}. Change-Id: I3a6668259556077cbb2986a9e8fe42a625d506c9 Reviewed-on: https://go-review.googlesource.com/22249 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michel Lespinasse <walken@google.com>
This commit is contained in:
parent
8b20fd000d
commit
998c8e034c
@ -160,18 +160,16 @@ func convT2E(t *_type, elem unsafe.Pointer, x unsafe.Pointer) (e eface) {
|
|||||||
msanread(elem, t.size)
|
msanread(elem, t.size)
|
||||||
}
|
}
|
||||||
if isDirectIface(t) {
|
if isDirectIface(t) {
|
||||||
e._type = t
|
throw("direct convT2E")
|
||||||
typedmemmove(t, unsafe.Pointer(&e.data), elem)
|
}
|
||||||
} else {
|
|
||||||
if x == nil {
|
if x == nil {
|
||||||
x = newobject(t)
|
x = newobject(t)
|
||||||
}
|
|
||||||
// TODO: We allocate a zeroed object only to overwrite it with
|
// TODO: We allocate a zeroed object only to overwrite it with
|
||||||
// actual data. Figure out how to avoid zeroing. Also below in convT2I.
|
// actual data. Figure out how to avoid zeroing. Also below in convT2I.
|
||||||
|
}
|
||||||
typedmemmove(t, x, elem)
|
typedmemmove(t, x, elem)
|
||||||
e._type = t
|
e._type = t
|
||||||
e.data = x
|
e.data = x
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,16 +182,14 @@ func convT2I(tab *itab, elem unsafe.Pointer, x unsafe.Pointer) (i iface) {
|
|||||||
msanread(elem, t.size)
|
msanread(elem, t.size)
|
||||||
}
|
}
|
||||||
if isDirectIface(t) {
|
if isDirectIface(t) {
|
||||||
i.tab = tab
|
throw("direct convT2I")
|
||||||
typedmemmove(t, unsafe.Pointer(&i.data), elem)
|
}
|
||||||
} else {
|
|
||||||
if x == nil {
|
if x == nil {
|
||||||
x = newobject(t)
|
x = newobject(t)
|
||||||
}
|
}
|
||||||
typedmemmove(t, x, elem)
|
typedmemmove(t, x, elem)
|
||||||
i.tab = tab
|
i.tab = tab
|
||||||
i.data = x
|
i.data = x
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user