]> Cypherpunks repositories - gostls13.git/commitdiff
spec: clarify size hint for make of maps
authorRobert Griesemer <gri@golang.org>
Tue, 11 Apr 2017 23:10:09 +0000 (16:10 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 13 Apr 2017 16:15:45 +0000 (16:15 +0000)
For #19903.

Change-Id: Ib28d08d45bfad653bcc1446f160b7b4a485529af
Reviewed-on: https://go-review.googlesource.com/40393
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
doc/go_spec.html

index 5ee8287889d840485dfcb54ca766a80a39ae89bd..0cc95bc64d6c383aaf330f652e27e5cfd2008610 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of March 24, 2017",
+       "Subtitle": "Version of April 12, 2017",
        "Path": "/ref/spec"
 }-->
 
@@ -5645,7 +5645,7 @@ make(T, n)       slice      slice of type T with length n and capacity n
 make(T, n, m)    slice      slice of type T with length n and capacity m
 
 make(T)          map        map of type T
-make(T, n)       map        map of type T with initial space for n elements
+make(T, n)       map        map of type T with initial space for approximately n elements
 
 make(T)          channel    unbuffered channel of type T
 make(T, n)       channel    buffered channel of type T, buffer size n
@@ -5668,9 +5668,15 @@ s := make([]int, 1e3)           // slice with len(s) == cap(s) == 1000
 s := make([]int, 1&lt;&lt;63)         // illegal: len(s) is not representable by a value of type int
 s := make([]int, 10, 0)         // illegal: len(s) > cap(s)
 c := make(chan int, 10)         // channel with a buffer size of 10
-m := make(map[string]int, 100)  // map with initial space for 100 elements
+m := make(map[string]int, 100)  // map with initial space for approximately 100 elements
 </pre>
 
+<p>
+Calling <code>make</code> with a map type and size hint <code>n</code> will
+create a map with initial space to hold <code>n</code> map elements.
+The precise behavior is implementation-dependent.
+</p>
+
 
 <h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>