Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(82)

Side by Side Diff: src/cmd/gofix/mapdelete.go

Issue 5448088: code review 5448088: cmd: shorten composite literal field values (Closed)
Patch Set: diff -r f91f50b96e10 https://go.googlecode.com/hg/ Created 12 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import "go/ast" 7 import "go/ast"
8 8
9 func init() { 9 func init() {
10 register(mapdeleteFix) 10 register(mapdeleteFix)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 if !canDrop(as.Rhs[0]) { 42 if !canDrop(as.Rhs[0]) {
43 warn(as.Pos(), "two-element map assignment with non-triv ial first value") 43 warn(as.Pos(), "two-element map assignment with non-triv ial first value")
44 return 44 return
45 } 45 }
46 *stmt = &ast.ExprStmt{ 46 *stmt = &ast.ExprStmt{
47 X: &ast.CallExpr{ 47 X: &ast.CallExpr{
48 Fun: &ast.Ident{ 48 Fun: &ast.Ident{
49 NamePos: as.Pos(), 49 NamePos: as.Pos(),
50 Name: "delete", 50 Name: "delete",
51 }, 51 },
52 » » » » Args: []ast.Expr{ix.X, ix.Index}, 52 » » » » Args: {ix.X, ix.Index},
gri 2011/12/02 23:11:05 I'd leave this file alone - no real win
53 }, 53 },
54 } 54 }
55 fixed = true 55 fixed = true
56 }) 56 })
57 return fixed 57 return fixed
58 } 58 }
59 59
60 // canDrop reports whether it is safe to drop the 60 // canDrop reports whether it is safe to drop the
61 // evaluation of n from the program. 61 // evaluation of n from the program.
62 // It is very conservative. 62 // It is very conservative.
(...skipping 17 matching lines...) Expand all
80 return true 80 return true
81 case *ast.StarExpr: 81 case *ast.StarExpr:
82 // Dropping *x is questionable, 82 // Dropping *x is questionable,
83 // but we have to be able to drop (*T)(nil). 83 // but we have to be able to drop (*T)(nil).
84 return canDrop(n.X) 84 return canDrop(n.X)
85 case *ast.ArrayType, *ast.ChanType, *ast.FuncType, *ast.InterfaceType, * ast.MapType, *ast.StructType: 85 case *ast.ArrayType, *ast.ChanType, *ast.FuncType, *ast.InterfaceType, * ast.MapType, *ast.StructType:
86 return true 86 return true
87 } 87 }
88 return false 88 return false
89 } 89 }
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b