From: Robert Griesemer Date: Tue, 22 Nov 2022 00:36:14 +0000 (-0800) Subject: spec: add a link to Allocation section in section on append built-in X-Git-Tag: go1.20rc1~99 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=72fdecafc0c1863f7540bd827a387e7e56836187;p=gostls13.git spec: add a link to Allocation section in section on append built-in If needed, the built-in function append allocates a new underlying array. While we (probably) don't want to specify exactly how much is allocated (the prose is deliberately vague), if there's more space allocated than needed (cap > len after allocation), that extra space is zeroed. Use an explicit link to the section on Allocation which explicitly states that newly allocated memory is zeroed. Fixes #56684. Change-Id: I9805d37c263b87860ea703ad143f738a0846247e Reviewed-on: https://go-review.googlesource.com/c/go/+/452619 Reviewed-by: Ian Lance Taylor Run-TryBot: Robert Griesemer Reviewed-by: Robert Griesemer Auto-Submit: Robert Griesemer TryBot-Result: Gopher Robot Reviewed-by: Joseph Tsai Reviewed-by: Matthew Dempsky --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 630012ded8..967bfc4b5c 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -7256,7 +7256,7 @@ append(s S, x ...E) S // core type of S is []E

If the capacity of s is not large enough to fit the additional -values, append allocates a new, sufficiently large underlying +values, append allocates a new, sufficiently large underlying array that fits both the existing slice elements and the additional values. Otherwise, append re-uses the underlying array.