From: Robert Griesemer Date: Tue, 11 Apr 2017 23:10:09 +0000 (-0700) Subject: spec: clarify size hint for make of maps X-Git-Tag: go1.9beta1~701 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b0e5a0c93ccf5166dab30864df7e5632a5973447;p=gostls13.git spec: clarify size hint for make of maps For #19903. Change-Id: Ib28d08d45bfad653bcc1446f160b7b4a485529af Reviewed-on: https://go-review.googlesource.com/40393 Reviewed-by: Rob Pike Reviewed-by: Russ Cox --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 5ee8287889..0cc95bc64d 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -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<<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 +

+Calling make with a map type and size hint n will +create a map with initial space to hold n map elements. +The precise behavior is implementation-dependent. +

+

Appending to and copying slices