]> Cypherpunks repositories - gostls13.git/commit
reflect: add MakeMapWithSize for creating maps with size hint
authorFilip GruszczyƄski <gruszczy@gmail.com>
Sat, 18 Mar 2017 03:10:38 +0000 (20:10 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 4 Apr 2017 20:01:43 +0000 (20:01 +0000)
commit6c5a819a5edd602236200627694215a1017aded2
treec735dcd266dfa67256745e63e7beb13df1196b6d
parentbe5a201e2a59dbe45157b8939a507830206d86fb
reflect: add MakeMapWithSize for creating maps with size hint

Providing size hint when creating a map allows avoiding re-allocating
underlying data structure if we know how many elements are going to
be inserted. This can be used for example during decoding maps in
gob.

Fixes #19599

Change-Id: I108035fec29391215d2261a73eaed1310b46bab1
Reviewed-on: https://go-review.googlesource.com/38335
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/reflect/all_test.go
src/reflect/value.go
src/runtime/hashmap.go