Skip to content

Commit c1359db

Browse files
committed
go/types: fix empty interface optimization (minor performance bug)
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 <[email protected]>
1 parent e2b5e60 commit c1359db

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/go/types/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (check *Checker) infoFromTypeLit(scope *Scope, iface *ast.InterfaceType, tn
186186
check.interfaces[tname] = nil // computation started but not complete
187187
}
188188

189-
if iface.Methods == nil {
189+
if iface.Methods.List == nil {
190190
// fast track for empty interface
191191
info = &emptyIfaceInfo
192192
} else {

src/go/types/typexpr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ func (check *Checker) declareInSet(oset *objset, pos token.Pos, obj Object) bool
473473

474474
func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, def *Named, path []*TypeName) {
475475
// fast-track empty interface
476-
if iface.Methods == nil {
476+
if iface.Methods.List == nil {
477477
ityp.allMethods = markComplete
478478
return
479479
}

0 commit comments

Comments
 (0)