]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: don't cache t.key.alg in evacuate
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 18 Aug 2017 01:01:05 +0000 (18:01 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 18 Aug 2017 18:20:10 +0000 (18:20 +0000)
The number of times that alg has to be spilled
and restored makes it better to just reload it.

Change-Id: I2674752a889ecad59dab54da1d68fad03db1ca85
Reviewed-on: https://go-review.googlesource.com/56931
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/hashmap.go

index cef41be4847acc8bed498ec6ace50e17d00a5a7d..f3434eb788c37418c15c00ccb3e0b550a93355fa 100644 (file)
@@ -1024,7 +1024,6 @@ func bucketEvacuated(t *maptype, h *hmap, bucket uintptr) bool {
 func evacuate(t *maptype, h *hmap, oldbucket uintptr) {
        b := (*bmap)(add(h.oldbuckets, oldbucket*uintptr(t.bucketsize)))
        newbit := h.noldbuckets()
-       alg := t.key.alg
        if !evacuated(b) {
                // TODO: reuse overflow buckets instead of using new ones, if there
                // is no iterator using the old buckets.  (If !oldIterator.)
@@ -1073,8 +1072,8 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) {
                                if !h.sameSizeGrow() {
                                        // Compute hash to make our evacuation decision (whether we need
                                        // to send this key/value to bucket x or bucket y).
-                                       hash := alg.hash(k2, uintptr(h.hash0))
-                                       if h.flags&iterator != 0 && !t.reflexivekey && !alg.equal(k2, k2) {
+                                       hash := t.key.alg.hash(k2, uintptr(h.hash0))
+                                       if h.flags&iterator != 0 && !t.reflexivekey && !t.key.alg.equal(k2, k2) {
                                                // If key != key (NaNs), then the hash could be (and probably
                                                // will be) entirely different from the old hash. Moreover,
                                                // it isn't reproducible. Reproducibility is required in the