]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: simplify switch statement to if statement
authoravsharapov <analytics.kzn@gmail.com>
Sat, 13 Oct 2018 10:51:16 +0000 (13:51 +0300)
committerIan Lance Taylor <iant@golang.org>
Mon, 15 Oct 2018 04:36:11 +0000 (04:36 +0000)
Change-Id: Ie7dce45d554fde69d682680f55abba6a7fc55036
Reviewed-on: https://go-review.googlesource.com/c/142017
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/cgo/gcc.go

index 019ee64c8e0202a8698d98594c8e40614dea389d..3058fc5f3415ab06a0f2b83ed2b22ec3322f09df 100644 (file)
@@ -1026,8 +1026,7 @@ func (p *Package) hasSideEffects(f *File, x ast.Expr) bool {
        found := false
        f.walk(x, ctxExpr,
                func(f *File, x interface{}, context astContext) {
-                       switch x.(type) {
-                       case *ast.CallExpr:
+                       if _, ok := x.(*ast.CallExpr); ok {
                                found = true
                        }
                })
@@ -1276,8 +1275,7 @@ func (p *Package) rewriteRef(f *File) {
                // in case expression being replaced is first on line.
                // See golang.org/issue/6563.
                pos := (*r.Expr).Pos()
-               switch x := expr.(type) {
-               case *ast.Ident:
+               if x, ok := expr.(*ast.Ident); ok {
                        expr = &ast.Ident{NamePos: pos, Name: x.Name}
                }