diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2017-08-11 08:21:31 -0700 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2017-08-15 00:19:22 +0000 |
| commit | c50a9718a6749c693ce13faaa0e1c4038bfb6c5e (patch) | |
| tree | 106db971655b864989f584c5c486669568d33433 /src/runtime/hashmap.go | |
| parent | 4b38200bfd2d4718730e63cc991e7163ed0d7fd9 (diff) | |
| download | go-c50a9718a6749c693ce13faaa0e1c4038bfb6c5e.tar.xz | |
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 <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/hashmap.go')
| -rw-r--r-- | src/runtime/hashmap.go | 2 |
1 files changed, 1 insertions, 1 deletions
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 { |
