From: Emmanuel Odeke Date: Wed, 21 Jun 2017 06:35:18 +0000 (-0600) Subject: reflect: match MakeMapWithSize docs about initial capacity with spec X-Git-Tag: go1.9rc1~102 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=79e1505e3b328e3623bd2e0c563fac65ac771612;p=gostls13.git 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 Reviewed-by: Russ Cox --- 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)} }