From a4956248a8b15cc8bb2fabce0be4a802e965ec3c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20M=C3=B6hrmann?= Date: Fri, 8 Sep 2017 23:05:19 +0200 Subject: [PATCH] runtime: move evacuateX evacuateY relation check from makemap to evacuate MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Move the check near the code in evacuate that relies on the relation evacuateX+1 == evacuateY. If the relation is fullfilled the check is known to be true at compile time and removed by the compiler. Change-Id: I711b75e09047bf347819ccaeec41d244a5883867 Reviewed-on: https://go-review.googlesource.com/62410 Run-TryBot: Martin Möhrmann TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/runtime/hashmap.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go index 1e76fc590c..4f47838cd4 100644 --- a/src/runtime/hashmap.go +++ b/src/runtime/hashmap.go @@ -296,11 +296,6 @@ func makemap(t *maptype, hint int, h *hmap) *hmap { hint = 0 } - if evacuatedX+1 != evacuatedY { - // evacuate relies on this relationship - throw("bad evacuatedN") - } - // initialize Hmap if h == nil { h = (*hmap)(newobject(t.hmap)) @@ -1061,7 +1056,11 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) { } } - b.tophash[i] = evacuatedX + useY // evacuatedX + 1 == evacuatedY, enforced in makemap + if evacuatedX+1 != evacuatedY { + throw("bad evacuatedN") + } + + b.tophash[i] = evacuatedX + useY // evacuatedX + 1 == evacuatedY dst := &xy[useY] // evacuation destination if dst.i == bucketCnt { -- 2.48.1