Commit 79e1505e authored by Emmanuel Odeke's avatar Emmanuel Odeke Committed by Russ Cox

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/46270Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 4e2eff4c
...@@ -2082,12 +2082,13 @@ func MakeMap(typ Type) Value { ...@@ -2082,12 +2082,13 @@ func MakeMap(typ Type) Value {
return MakeMapWithSize(typ, 0) return MakeMapWithSize(typ, 0)
} }
// MakeMapWithSize creates a new map with the specified type and initial capacity. // MakeMapWithSize creates a new map with the specified type
func MakeMapWithSize(typ Type, cap int) Value { // and initial space for approximately n elements.
func MakeMapWithSize(typ Type, n int) Value {
if typ.Kind() != Map { if typ.Kind() != Map {
panic("reflect.MakeMapWithSize of non-map type") panic("reflect.MakeMapWithSize of non-map type")
} }
m := makemap(typ.(*rtype), cap) m := makemap(typ.(*rtype), n)
return Value{typ.common(), m, flag(Map)} return Value{typ.common(), m, flag(Map)}
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment