diff options
author | Emmanuel Odeke <emm.odeke@gmail.com> | 2017-06-21 00:35:18 -0600 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2017-07-06 04:04:20 +0000 |
commit | 79e1505e3b328e3623bd2e0c563fac65ac771612 (patch) | |
tree | 675862a7f32bfdfddb55618e914c70c70e4944af /src/reflect | |
parent | 4e2eff4c9b7a4c67c7c0af5f226f3292065c9dca (diff) | |
download | go-git-79e1505e3b328e3623bd2e0c563fac65ac771612.tar.gz |
reflect: match MakeMapWithSize docs about initial capacity with spec
Following the spec clarification in CL 40393, copy that text
to reflect docs to state that the initial capacity of MakeMapWithSize
is a hint/approximate.
Fixes #19903
Change-Id: I6b3315b8183cafaa61fbb2839a4e42b76fd71544
Reviewed-on: https://go-review.googlesource.com/46270
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/value.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/reflect/value.go b/src/reflect/value.go index 3d73338809..8488e8dec1 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -2082,12 +2082,13 @@ func MakeMap(typ Type) Value { return MakeMapWithSize(typ, 0) } -// MakeMapWithSize creates a new map with the specified type and initial capacity. -func MakeMapWithSize(typ Type, cap int) Value { +// MakeMapWithSize creates a new map with the specified type +// and initial space for approximately n elements. +func MakeMapWithSize(typ Type, n int) Value { if typ.Kind() != Map { panic("reflect.MakeMapWithSize of non-map type") } - m := makemap(typ.(*rtype), cap) + m := makemap(typ.(*rtype), n) return Value{typ.common(), m, flag(Map)} } |