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
ianlancetaylor
changed the title
Zero unused portion of temp buffer in stringtoslice{byte,rune}
runtime: zero unused portion of temp buffer in stringtoslice{byte,rune}
Feb 5, 2016
Zeroing the tmpBuf is only 4 instructions (on amd64), so it is probably worth it. It allows things like the append in the following function to work without allocation:
func g(s, t string) string {
b := ([]byte)(s)
b = append(b, ([]byte)(t)...)
return string(b)
}
Maybe we should zero the unused portion of the temp buffer instead of reducing the capacity of the returned slice.
See issue #14232
The text was updated successfully, but these errors were encountered: