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: