]> Cypherpunks.ru repositories - gostls13.git/commitdiff
spec: add a link to Allocation section in section on append built-in
authorRobert Griesemer <gri@golang.org>
Tue, 22 Nov 2022 00:36:14 +0000 (16:36 -0800)
committerGopher Robot <gobot@golang.org>
Wed, 23 Nov 2022 00:25:09 +0000 (00:25 +0000)
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 <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
doc/go_spec.html

index 630012ded898d1c6dd7f55c532d6ded981615230..967bfc4b5cb5752feb4d71f202efa7d4f27f6f8f 100644 (file)
@@ -7256,7 +7256,7 @@ append(s S, x ...E) S  // core type of S is []E
 
 <p>
 If the capacity of <code>s</code> is not large enough to fit the additional
-values, <code>append</code> allocates a new, sufficiently large underlying
+values, <code>append</code> <a href="#Allocation">allocates</a> a new, sufficiently large underlying
 array that fits both the existing slice elements and the additional values.
 Otherwise, <code>append</code> re-uses the underlying array.
 </p>