x/exp/slices: Grow should not mutate bytes between length and capacity #53853
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
The documentation of Grow says:
While this is just a "may", in practice it does, which leads to poor performance.
Suppose I had some logic that did something like:
In the event that
dst
is large enough, I would expect that every call toslices.Grow
to effectively be a noop.However, that is not what happens. Instead, it always zeroes out the space between
dst[len(dst):len(dst)+n]
.The performance cost of this is evident with this simple benchmark:
which prints:
I would expect it to be something like:
\cc @ianlancetaylor @eliben
The text was updated successfully, but these errors were encountered: