From: Martin Möhrmann Date: Wed, 16 Aug 2017 21:52:16 +0000 (+0200) Subject: runtime: avoid zeroing hmap fields in makemap twice X-Git-Tag: go1.10beta1~1489 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b6296426a065b85d4c1abbc7012dd633c33bb3c2;p=gostls13.git runtime: avoid zeroing hmap fields in makemap twice Stack allocated hmap structs are explicitly zeroed before being passed by pointer to makemap. Heap allocated hmap structs are created with newobject which also zeroes on allocation. Therefore, setting the hmap fields to 0 or nil is redundant since they will have been zeroed when hmap was allocated. Change-Id: I5fc55b75e9dc5ba69f5e3588d6c746f53b45ba66 Reviewed-on: https://go-review.googlesource.com/56291 Reviewed-by: Keith Randall --- diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go index 3e413e52f7..28ea376cf4 100644 --- a/src/runtime/hashmap.go +++ b/src/runtime/hashmap.go @@ -335,15 +335,10 @@ func makemap(t *maptype, hint int64, h *hmap, bucket unsafe.Pointer) *hmap { if h == nil { h = (*hmap)(newobject(t.hmap)) } - h.count = 0 h.B = B h.extra = extra - h.flags = 0 h.hash0 = fastrand() h.buckets = buckets - h.oldbuckets = nil - h.nevacuate = 0 - h.noverflow = 0 return h }