]> Cypherpunks repositories - gostls13.git/commit
reflect: add Value.Grow
authorJoe Tsai <joetsai@digital-static.net>
Wed, 2 Mar 2022 21:01:48 +0000 (13:01 -0800)
committerJoseph Tsai <joetsai@digital-static.net>
Sat, 15 Oct 2022 17:02:11 +0000 (17:02 +0000)
commit61f0409c31cad8729d7982425d353d7b2ea80534
tree017883773a9694862745945370b7ff6630526d9e
parent9ddb8ea73724d717a9bbf44be7d585ba5587504f
reflect: add Value.Grow

The Grow method is like the proposed slices.Grow function
in that it ensures that the slice has enough capacity to append
n elements without allocating.

The implementation of Grow is a thin wrapper over runtime.growslice.
This also changes Append and AppendSlice to use growslice under the hood.

Fixes #48000

Change-Id: I992a58584a2ff1448c1c2bc0877fe76073609111
Reviewed-on: https://go-review.googlesource.com/c/go/+/389635
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
api/next/48000.txt [new file with mode: 0644]
src/reflect/all_test.go
src/reflect/value.go
src/runtime/slice.go