From 79e1505e3b328e3623bd2e0c563fac65ac771612 Mon Sep 17 00:00:00 2001 From: Emmanuel Odeke Date: Wed, 21 Jun 2017 00:35:18 -0600 Subject: 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 --- src/reflect/value.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/reflect') 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)} } -- cgit v1.2.1