Commit cea04881 authored by Aaron Jacobs's avatar Aaron Jacobs

buffer: generate decent code for OutMessage.Reset in Go 1.8 beta 2.

parent bd496ea0
......@@ -55,8 +55,22 @@ func init() {
// Reset resets m so that it's ready to be used again. Afterward, the contents
// are solely a zeroed fusekernel.OutHeader struct.
func (m *OutMessage) Reset() {
m.payloadOffset = 0
m.header = fusekernel.OutHeader{}
// Ideally we'd like to write:
//
// m.payloadOffset = 0
// m.header = fusekernel.OutHeader{}
//
// But Go 1.8 beta 2 generates bad code for this
// (https://golang.org/issue/18370). Encourage it to generate the same code
// as Go 1.7.4 did.
if unsafe.Offsetof(m.payload) != 24 {
panic("unexpected OutMessage layout")
}
a := (*[3]uint64)(unsafe.Pointer(m))
a[0] = 0
a[1] = 0
a[2] = 0
}
// OutHeader returns a pointer to the header at the start of the message.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment