From c50a9718a6749c693ce13faaa0e1c4038bfb6c5e Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Fri, 11 Aug 2017 08:21:31 -0700 Subject: [PATCH] runtime: mask a bounded slice access in hashmap evacuate Shaves a few instructions off. Change-Id: I39f1b01ae7e770d632d5e77a6aa4b5a1f123b41a Reviewed-on: https://go-review.googlesource.com/55090 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/runtime/hashmap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go index 1f16fe4e56..22470a08e9 100644 --- a/src/runtime/hashmap.go +++ b/src/runtime/hashmap.go @@ -1129,7 +1129,7 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) { dst.k = add(unsafe.Pointer(dst.b), dataOffset) dst.v = add(dst.k, bucketCnt*uintptr(t.keysize)) } - dst.b.tophash[dst.i] = top + dst.b.tophash[dst.i&(bucketCnt-1)] = top // mask dst.i as an optimization, to avoid a bounds check if t.indirectkey { *(*unsafe.Pointer)(dst.k) = k2 // copy pointer } else {