Skip to content

Commit a5a249d

Browse files
callthingsoffgopherbot
authored andcommitted
all: eliminate unnecessary type conversions
Found by github.com/mdempsky/unconvert Change-Id: I88ce10390a49ba768a4deaa0df9057c93c1164de GitHub-Last-Rev: 3b0f7e8 GitHub-Pull-Request: #75974 Reviewed-on: https://go-review.googlesource.com/c/go/+/712940 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com>
1 parent 694182d commit a5a249d

File tree

61 files changed

+202
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+202
-203
lines changed

src/cmd/asm/internal/asm/asm.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func (p *Parser) asmData(operands [][]lex.Token) {
248248
case obj.TYPE_CONST:
249249
switch sz {
250250
case 1, 2, 4, 8:
251-
nameAddr.Sym.WriteInt(p.ctxt, nameAddr.Offset, int(sz), valueAddr.Offset)
251+
nameAddr.Sym.WriteInt(p.ctxt, nameAddr.Offset, sz, valueAddr.Offset)
252252
default:
253253
p.errorf("bad int size for DATA argument: %d", sz)
254254
}
@@ -262,10 +262,10 @@ func (p *Parser) asmData(operands [][]lex.Token) {
262262
p.errorf("bad float size for DATA argument: %d", sz)
263263
}
264264
case obj.TYPE_SCONST:
265-
nameAddr.Sym.WriteString(p.ctxt, nameAddr.Offset, int(sz), valueAddr.Val.(string))
265+
nameAddr.Sym.WriteString(p.ctxt, nameAddr.Offset, sz, valueAddr.Val.(string))
266266
case obj.TYPE_ADDR:
267267
if sz == p.arch.PtrSize {
268-
nameAddr.Sym.WriteAddr(p.ctxt, nameAddr.Offset, int(sz), valueAddr.Sym, valueAddr.Offset)
268+
nameAddr.Sym.WriteAddr(p.ctxt, nameAddr.Offset, sz, valueAddr.Sym, valueAddr.Offset)
269269
} else {
270270
p.errorf("bad addr size for DATA argument: %d", sz)
271271
}

src/cmd/cgo/gcc.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,7 +2154,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
21542154
for _, s := range f.Symbols {
21552155
switch {
21562156
case isDebugInts(s.Name):
2157-
if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
2157+
if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
21582158
sect := f.Sections[i]
21592159
if s.Value < sect.Size {
21602160
if sdat, err := sect.Data(); err == nil {
@@ -2167,7 +2167,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
21672167
}
21682168
}
21692169
case isDebugFloats(s.Name):
2170-
if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
2170+
if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
21712171
sect := f.Sections[i]
21722172
if s.Value < sect.Size {
21732173
if sdat, err := sect.Data(); err == nil {
@@ -2181,7 +2181,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
21812181
}
21822182
default:
21832183
if n := indexOfDebugStr(s.Name); n != -1 {
2184-
if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
2184+
if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
21852185
sect := f.Sections[i]
21862186
if s.Value < sect.Size {
21872187
if sdat, err := sect.Data(); err == nil {
@@ -2193,7 +2193,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
21932193
break
21942194
}
21952195
if n := indexOfDebugStrlen(s.Name); n != -1 {
2196-
if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
2196+
if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
21972197
sect := f.Sections[i]
21982198
if s.Value < sect.Size {
21992199
if sdat, err := sect.Data(); err == nil {

src/cmd/cgo/internal/swig/swig_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func mustHaveCxx(t *testing.T) {
8080
if len(args) == 0 {
8181
t.Skip("no C++ compiler")
8282
}
83-
testenv.MustHaveExecPath(t, string(args[0]))
83+
testenv.MustHaveExecPath(t, args[0])
8484
}
8585

8686
var (

src/cmd/cgo/internal/testcarchive/carchive_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ func testMain(m *testing.M) int {
102102
bin = cmdToRun("./testp")
103103

104104
ccOut := goEnv("CC")
105-
cc = []string{string(ccOut)}
105+
cc = []string{ccOut}
106106

107107
out := goEnv("GOGCCFLAGS")
108108
quote := '\000'
109109
start := 0
110110
lastSpace := true
111111
backslash := false
112-
s := string(out)
112+
s := out
113113
for i, c := range s {
114114
if quote == '\000' && unicode.IsSpace(c) {
115115
if !lastSpace {

src/cmd/cgo/internal/testcshared/cshared_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func testMain(m *testing.M) int {
7676
start := 0
7777
lastSpace := true
7878
backslash := false
79-
s := string(out)
79+
s := out
8080
for i, c := range s {
8181
if quote == '\000' && unicode.IsSpace(c) {
8282
if !lastSpace {

src/cmd/cgo/internal/testerrors/badsym_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func cCompilerCmd(t *testing.T) []string {
186186
start := 0
187187
lastSpace := true
188188
backslash := false
189-
s := string(out)
189+
s := out
190190
for i, c := range s {
191191
if quote == '\000' && unicode.IsSpace(c) {
192192
if !lastSpace {

src/cmd/compile/internal/coverage/cover.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func metaHashAndLen() ([16]byte, int) {
131131
}
132132
var hv [16]byte
133133
for i := 0; i < 16; i++ {
134-
nib := string(mhash[i*2 : i*2+2])
134+
nib := mhash[i*2 : i*2+2]
135135
x, err := strconv.ParseInt(nib, 16, 32)
136136
if err != nil {
137137
base.Fatalf("metahash bad byte %q", nib)

src/cmd/compile/internal/inline/inl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func CanInline(fn *ir.Func, profile *pgoir.Profile) {
289289
// function is inlinable.
290290
func noteInlinableFunc(n *ir.Name, fn *ir.Func, cost int32) {
291291
if base.Flag.LowerM > 1 {
292-
fmt.Printf("%v: can inline %v with cost %d as: %v { %v }\n", ir.Line(fn), n, cost, fn.Type(), ir.Nodes(fn.Body))
292+
fmt.Printf("%v: can inline %v with cost %d as: %v { %v }\n", ir.Line(fn), n, cost, fn.Type(), fn.Body)
293293
} else if base.Flag.LowerM != 0 {
294294
fmt.Printf("%v: can inline %v\n", ir.Line(fn), n)
295295
}

src/cmd/compile/internal/ir/bitset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (f *bitset8) set2(shift uint8, b uint8) {
2323
// Clear old bits.
2424
*(*uint8)(f) &^= 3 << shift
2525
// Set new bits.
26-
*(*uint8)(f) |= uint8(b&3) << shift
26+
*(*uint8)(f) |= (b & 3) << shift
2727
}
2828

2929
type bitset16 uint16

src/cmd/compile/internal/loong64/ssa.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,8 +1175,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
11751175
p.From.Type = obj.TYPE_MEM
11761176
p.From.Reg = v.Args[0].Reg()
11771177
p.AddRestSourceArgs([]obj.Addr{
1178-
{Type: obj.TYPE_CONST, Offset: int64((v.AuxInt >> 5) & 0x1fffffffff)},
1179-
{Type: obj.TYPE_CONST, Offset: int64((v.AuxInt >> 0) & 0x1f)},
1178+
{Type: obj.TYPE_CONST, Offset: (v.AuxInt >> 5) & 0x1fffffffff},
1179+
{Type: obj.TYPE_CONST, Offset: (v.AuxInt >> 0) & 0x1f},
11801180
})
11811181

11821182
case ssa.OpLOONG64ADDshiftLLV:

0 commit comments

Comments
 (0)