runtime: gobytes() initializes allocated memory unnecessarily #23634
Labels
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Performance
release-blocker
Milestone
I noticed this in the go1.9 sources, though this also applies to go1.10.
runtime.gobytes
currently usesmake([]byte, ...)
and then immediately overwrites the data in the slice:The zero initialization of the slice by
make
is a small but noticeable performance hit when copying a large chunk of memory viaC.GoBytes
. The allocation can be replaced withrawbyteslice(n)
which already exists for the purpose of allocating an uninitialized[]byte
.The text was updated successfully, but these errors were encountered: