On 11/13/19 9:50 PM, Nick Rosbrook wrote: >> What's the point of this? >> >> I realize it's slightly annoying to have to type `mac[0], mac[1], ...`, >> but I'd rather do that once than make the runtime copy everything over >> into a slice of interfaces every String() call. > > As I think you realized by looking at subsequent patches, this is to > get around the fact that "an array of an interface type != an array of > type that implements that interface." Since this is a small array, I'm > fine with explicitly passing each element of the array to fmt.Sprintf.
Using `mac[0], mac[1], ...` for this one is kind of just on the border of reasonable, but when I got to a later patch, I felt like `uuid[0], uuid[1], ... uuid[15]` was a bit much. And on further reflection, the fact is that all of these will be changed to interface{} under the hood by the function call and then reflect'ed to determine their type anyway; i.e., I'm pretty sure: fmt.Sprintf(s, mac[0], mac[1], /* &c */) from a compiler perspective is basically identical to: fmt.Sprintf(s, []interface{}{mac[0], mac[1], /* &c */}...) So the code you have is probably going to be about equally efficient anyway. So I guess, unless you feel strongly that using `mac[0], mac[1], ...` is a better way to go, maybe just leave it the way it is for now. -George _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel