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
A pattern that I've been finding myself writing a lot recently is
func somefunc() string {
b := make([]byte, 0, somecap)
// build a string component by component
return string(b)
}
In the case where we don't touch the byte slice after the string conversion and the byte slice otherwise doesn't escape, we can allocate the slice on the heap and use the non-copying slicetostringtmp function to create the string, eliminating copying and an allocation.
The text was updated successfully, but these errors were encountered:
A pattern that I've been finding myself writing a lot recently is
In the case where we don't touch the byte slice after the string conversion and the byte slice otherwise doesn't escape, we can allocate the slice on the heap and use the non-copying slicetostringtmp function to create the string, eliminating copying and an allocation.
The text was updated successfully, but these errors were encountered: