Commit b0e5a0c9 authored by Robert Griesemer's avatar Robert Griesemer

spec: clarify size hint for make of maps

For #19903.

Change-Id: Ib28d08d45bfad653bcc1446f160b7b4a485529af
Reviewed-on: https://go-review.googlesource.com/40393Reviewed-by: 's avatarRob Pike <r@golang.org>
Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent 55b56d2b
<!--{
"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>
......
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