You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The generated code of ExtractInteresting only copies the interesting string, not the padding around it.
What did you see instead?
The generated code first initializes a variable of type Large on the stack (repz stosq). Then it copies the whole struct to the stack (repz movsq). Then it extracts the interesting field.
A real-life example of this pattern can be found in the pkglint project, where an interface is used to emulate a union type. That interface is accessed in many of the accessor methods, such as Varname. In that code I used a struct instead of a pointer to struct, since I wanted to avoid the extra dereference. I had expected that avoiding the pointer would result in faster code.
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?go version go1.11.1 windows/amd64
Does this issue reproduce with the latest release?
yes
What did you do?
What did you expect to see?
The generated code of
ExtractInteresting
only copies the interesting string, not the padding around it.What did you see instead?
The generated code first initializes a variable of type
Large
on the stack (repz stosq
). Then it copies the whole struct to the stack (repz movsq
). Then it extracts the interesting field.A real-life example of this pattern can be found in the pkglint project, where an interface is used to emulate a union type. That interface is accessed in many of the accessor methods, such as Varname. In that code I used a struct instead of a pointer to struct, since I wanted to avoid the extra dereference. I had expected that avoiding the pointer would result in faster code.
The text was updated successfully, but these errors were encountered: