]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: remove indentation in evacuate
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 10 Aug 2017 13:46:36 +0000 (06:46 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 14 Aug 2017 00:51:02 +0000 (00:51 +0000)
Combine conditions into a single if statement.
This is more readable.

It should generate identical machine code, but it doesn't.
The new code is shorter.

Change-Id: I9bf52f8f288b0df97a2b9b4e4183f6ca74175e8a
Reviewed-on: https://go-review.googlesource.com/54651
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
src/runtime/hashmap.go

index 11ce0cbc4b831daf808f50b1c78699a2fd0d00cd..e8e61a7fd15dc8f515b512f8a254c63fcd9c3132 100644 (file)
@@ -1088,28 +1088,26 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) {
                                        // 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 {
-                                               if !t.reflexivekey && !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
-                                                       // presence of iterators, as our evacuation decision must
-                                                       // match whatever decision the iterator made.
-                                                       // Fortunately, we have the freedom to send these keys either
-                                                       // way. Also, tophash is meaningless for these kinds of keys.
-                                                       // We let the low bit of tophash drive the evacuation decision.
-                                                       // We recompute a new random tophash for the next level so
-                                                       // these keys will get evenly distributed across all buckets
-                                                       // after multiple grows.
-                                                       if top&1 != 0 {
-                                                               hash |= newbit
-                                                       } else {
-                                                               hash &^= newbit
-                                                       }
-                                                       top = uint8(hash >> (sys.PtrSize*8 - 8))
-                                                       if top < minTopHash {
-                                                               top += minTopHash
-                                                       }
+                                       if h.flags&iterator != 0 && !t.reflexivekey && !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
+                                               // presence of iterators, as our evacuation decision must
+                                               // match whatever decision the iterator made.
+                                               // Fortunately, we have the freedom to send these keys either
+                                               // way. Also, tophash is meaningless for these kinds of keys.
+                                               // We let the low bit of tophash drive the evacuation decision.
+                                               // We recompute a new random tophash for the next level so
+                                               // these keys will get evenly distributed across all buckets
+                                               // after multiple grows.
+                                               if top&1 != 0 {
+                                                       hash |= newbit
+                                               } else {
+                                                       hash &^= newbit
+                                               }
+                                               top = uint8(hash >> (sys.PtrSize*8 - 8))
+                                               if top < minTopHash {
+                                                       top += minTopHash
                                                }
                                        }
                                        useX = hash&newbit == 0