]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: match MakeMapWithSize docs about initial capacity with spec
authorEmmanuel Odeke <emm.odeke@gmail.com>
Wed, 21 Jun 2017 06:35:18 +0000 (00:35 -0600)
committerRuss Cox <rsc@golang.org>
Thu, 6 Jul 2017 04:04:20 +0000 (04:04 +0000)
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>
src/reflect/value.go

index 3d73338809420ba7c45d42c5bc5d7e527313a38d..8488e8dec120dedf8ad3c15ef014f7917f10d0ac 100644 (file)
@@ -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)}
 }