From 6c9e55bd06181ee966047d45c963bbfca3e5279f Mon Sep 17 00:00:00 2001 From: Jaden Weiss Date: Mon, 23 Sep 2019 10:46:08 -0400 Subject: [PATCH] reflect: delete incorrect optimization --- compiler/reflect.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/compiler/reflect.go b/compiler/reflect.go index da155e16..8c0c82ce 100644 --- a/compiler/reflect.go +++ b/compiler/reflect.go @@ -126,15 +126,8 @@ type typeCodeAssignmentState struct { // that is ever stored in an interface. It tries to use the smallest possible // numbers to make the code that works with interfaces as small as possible. func (c *Compiler) assignTypeCodes(typeSlice typeInfoSlice) { - fn := c.mod.NamedFunction("reflect.ValueOf") - if fn.IsNil() { - // reflect.ValueOf is never used, so we can use the most efficient - // encoding possible. - for i, t := range typeSlice { - t.num = uint64(i + 1) - } - return - } + // if reflect were not used, we could skip generating the sidetable + // this does not help in practice, and is difficult to do correctly // Assign typecodes the way the reflect package expects. state := typeCodeAssignmentState{