]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: remove nil check around range
authorDaniel Martí <mvdan@mvdan.cc>
Wed, 9 Aug 2017 07:24:14 +0000 (16:24 +0900)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 10 Aug 2017 12:17:11 +0000 (12:17 +0000)
Ranging over a nil slice is a no-op, so guarding it with a nil check is
not useful.

Found with honnef.co/go/tools/cmd/staticcheck.

Change-Id: I6ce56bb6805809ca29349257f10fd69c30611643
Reviewed-on: https://go-review.googlesource.com/54131
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/types/stmt.go

index 4e423bd686ffbb08066e32fe8a4237fb98ebd216..f4feabefdd6910d7fccd272d30ba97816cc482f6 100644 (file)
@@ -236,15 +236,13 @@ L:
                }
                // look for duplicate values
                if val := goVal(v.val); val != nil {
-                       if list := seen[val]; list != nil {
-                               // look for duplicate types for a given value
-                               // (quadratic algorithm, but these lists tend to be very short)
-                               for _, vt := range list {
-                                       if Identical(v.typ, vt.typ) {
-                                               check.errorf(v.pos(), "duplicate case %s in expression switch", &v)
-                                               check.error(vt.pos, "\tprevious case") // secondary error, \t indented
-                                               continue L
-                                       }
+                       // look for duplicate types for a given value
+                       // (quadratic algorithm, but these lists tend to be very short)
+                       for _, vt := range seen[val] {
+                               if Identical(v.typ, vt.typ) {
+                                       check.errorf(v.pos(), "duplicate case %s in expression switch", &v)
+                                       check.error(vt.pos, "\tprevious case") // secondary error, \t indented
+                                       continue L
                                }
                        }
                        seen[val] = append(seen[val], valueType{v.pos(), v.typ})