]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: fix empty interface optimization (minor performance bug)
authorRobert Griesemer <gri@golang.org>
Tue, 27 Feb 2018 23:39:42 +0000 (15:39 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 28 Feb 2018 18:22:21 +0000 (18:22 +0000)
The tests checking for empty interfaces so that they can be fast-
tracked in the code actually didn't test the right field and the
fast track code never executed. Doing it now.

Change-Id: I58b2951efb3fb40b3366874c79fd653591ae0e99
Reviewed-on: https://go-review.googlesource.com/97519
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/types/interfaces.go
src/go/types/typexpr.go

index 66669ce36bed6c5c19acbd59179e6cde34822101..d82f1c83ebbba65dd6c5697c89df765c26aa1faa 100644 (file)
@@ -186,7 +186,7 @@ func (check *Checker) infoFromTypeLit(scope *Scope, iface *ast.InterfaceType, tn
                check.interfaces[tname] = nil // computation started but not complete
        }
 
-       if iface.Methods == nil {
+       if iface.Methods.List == nil {
                // fast track for empty interface
                info = &emptyIfaceInfo
        } else {
index 7ba5fd4389c1efd0f865338d34750b6644441032..18234cb19d0ca79fc10bdef2f649f2a395df177c 100644 (file)
@@ -473,7 +473,7 @@ func (check *Checker) declareInSet(oset *objset, pos token.Pos, obj Object) bool
 
 func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, def *Named, path []*TypeName) {
        // fast-track empty interface
-       if iface.Methods == nil {
+       if iface.Methods.List == nil {
                ityp.allMethods = markComplete
                return
        }