Skip to content

Commit 0273d36

Browse files
committed
all: remove unnecessary type conversions
Change-Id: I942be4fee89d3b516f41ca8d32ea705d0b5d92d4
1 parent 6fbad4b commit 0273d36

26 files changed

+59
-59
lines changed

src/bytes/bytes_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,14 +693,14 @@ func bmIndexRuneUnicode(rt *unicode.RangeTable, needle rune) func(b *testing.B,
693693
for _, r16 := range rt.R16 {
694694
for r := rune(r16.Lo); r <= rune(r16.Hi); r += rune(r16.Stride) {
695695
if r != needle {
696-
rs = append(rs, rune(r))
696+
rs = append(rs, r)
697697
}
698698
}
699699
}
700700
for _, r32 := range rt.R32 {
701701
for r := rune(r32.Lo); r <= rune(r32.Hi); r += rune(r32.Stride) {
702702
if r != needle {
703-
rs = append(rs, rune(r))
703+
rs = append(rs, r)
704704
}
705705
}
706706
}

src/debug/dwarf/entry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ func (b *buf) entry(cu *Entry, u *unit) *Entry {
554554
case formData16:
555555
val = b.bytes(16)
556556
case formSdata:
557-
val = int64(b.int())
557+
val = b.int()
558558
case formUdata:
559559
val = int64(b.uint())
560560
case formImplicitConst:

src/net/cgo_unix_syscall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func _C_res_nclose(state *_C_struct___res_state) {
8585

8686
func cgoNameinfoPTR(b []byte, sa *syscall.RawSockaddr, salen int) (int, error) {
8787
gerrno, err := unix.Getnameinfo(sa, salen, &b[0], len(b), nil, 0, unix.NI_NAMEREQD)
88-
return int(gerrno), err
88+
return gerrno, err
8989
}
9090

9191
func cgoSockaddrInet4(ip IP) *syscall.RawSockaddr {

src/net/tcpconn_keepalive_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestTCPConnKeepAliveConfigDialer(t *testing.T) {
2222
oldCfg KeepAliveConfig
2323
)
2424
testPreHookSetKeepAlive = func(nfd *netFD) {
25-
oldCfg, errHook = getCurrentKeepAliveSettings(fdType(nfd.pfd.Sysfd))
25+
oldCfg, errHook = getCurrentKeepAliveSettings(nfd.pfd.Sysfd)
2626
}
2727

2828
handler := func(ls *localServer, ln Listener) {
@@ -80,7 +80,7 @@ func TestTCPConnKeepAliveConfigListener(t *testing.T) {
8080
oldCfg KeepAliveConfig
8181
)
8282
testPreHookSetKeepAlive = func(nfd *netFD) {
83-
oldCfg, errHook = getCurrentKeepAliveSettings(fdType(nfd.pfd.Sysfd))
83+
oldCfg, errHook = getCurrentKeepAliveSettings(nfd.pfd.Sysfd)
8484
}
8585

8686
ch := make(chan Conn, 1)

src/runtime/heapdump.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ func dumproots() {
460460
continue
461461
}
462462
spf := (*specialfinalizer)(unsafe.Pointer(sp))
463-
p := unsafe.Pointer(s.base() + uintptr(spf.special.offset))
463+
p := unsafe.Pointer(s.base() + spf.special.offset)
464464
dumpfinalizer(p, spf.fn, spf.fint, spf.ot)
465465
}
466466
}
@@ -659,7 +659,7 @@ func dumpmemprof() {
659659
continue
660660
}
661661
spp := (*specialprofile)(unsafe.Pointer(sp))
662-
p := s.base() + uintptr(spp.special.offset)
662+
p := s.base() + spp.special.offset
663663
dumpint(tagAllocSample)
664664
dumpint(uint64(p))
665665
dumpint(uint64(uintptr(unsafe.Pointer(spp.b))))

src/runtime/mcleanup.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,14 @@ func (c Cleanup) Stop() {
173173
// Reached the end of the linked list. Stop searching at this point.
174174
break
175175
}
176-
if offset == uintptr(s.offset) && _KindSpecialCleanup == s.kind &&
176+
if offset == s.offset && _KindSpecialCleanup == s.kind &&
177177
(*specialCleanup)(unsafe.Pointer(s)).id == c.id {
178178
// The special is a cleanup and contains a matching cleanup id.
179179
*iter = s.next
180180
found = s
181181
break
182182
}
183-
if offset < uintptr(s.offset) || (offset == uintptr(s.offset) && _KindSpecialCleanup < s.kind) {
183+
if offset < s.offset || (offset == s.offset && _KindSpecialCleanup < s.kind) {
184184
// The special is outside the region specified for that kind of
185185
// special. The specials are sorted by kind.
186186
break

src/runtime/mgcmark.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ func gcScanFinalizer(spf *specialfinalizer, s *mspan, gcw *gcWork) {
415415
// Don't mark finalized object, but scan it so we retain everything it points to.
416416

417417
// A finalizer can be set for an inner byte of an object, find object beginning.
418-
p := s.base() + uintptr(spf.special.offset)/s.elemsize*s.elemsize
418+
p := s.base() + spf.special.offset/s.elemsize*s.elemsize
419419

420420
// Mark everything that can be reached from
421421
// the object (but *not* the object itself or

src/runtime/mgcsweep.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,15 @@ func (sl *sweepLocked) sweep(preserve bool) bool {
553553
siter := newSpecialsIter(s)
554554
for siter.valid() {
555555
// A finalizer can be set for an inner byte of an object, find object beginning.
556-
objIndex := uintptr(siter.s.offset) / size
556+
objIndex := siter.s.offset / size
557557
p := s.base() + objIndex*size
558558
mbits := s.markBitsForIndex(objIndex)
559559
if !mbits.isMarked() {
560560
// This object is not marked and has at least one special record.
561561
// Pass 1: see if it has a finalizer.
562562
hasFinAndRevived := false
563563
endOffset := p - s.base() + size
564-
for tmp := siter.s; tmp != nil && uintptr(tmp.offset) < endOffset; tmp = tmp.next {
564+
for tmp := siter.s; tmp != nil && tmp.offset < endOffset; tmp = tmp.next {
565565
if tmp.kind == _KindSpecialFinalizer {
566566
// Stop freeing of object if it has a finalizer.
567567
mbits.setMarkedNonAtomic()
@@ -573,11 +573,11 @@ func (sl *sweepLocked) sweep(preserve bool) bool {
573573
// Pass 2: queue all finalizers and clear any weak handles. Weak handles are cleared
574574
// before finalization as specified by the weak package. See the documentation
575575
// for that package for more details.
576-
for siter.valid() && uintptr(siter.s.offset) < endOffset {
576+
for siter.valid() && siter.s.offset < endOffset {
577577
// Find the exact byte for which the special was setup
578578
// (as opposed to object beginning).
579579
special := siter.s
580-
p := s.base() + uintptr(special.offset)
580+
p := s.base() + special.offset
581581
if special.kind == _KindSpecialFinalizer || special.kind == _KindSpecialWeakHandle {
582582
siter.unlinkAndNext()
583583
freeSpecial(special, unsafe.Pointer(p), size)
@@ -589,11 +589,11 @@ func (sl *sweepLocked) sweep(preserve bool) bool {
589589
}
590590
} else {
591591
// Pass 2: the object is truly dead, free (and handle) all specials.
592-
for siter.valid() && uintptr(siter.s.offset) < endOffset {
592+
for siter.valid() && siter.s.offset < endOffset {
593593
// Find the exact byte for which the special was setup
594594
// (as opposed to object beginning).
595595
special := siter.s
596-
p := s.base() + uintptr(special.offset)
596+
p := s.base() + special.offset
597597
siter.unlinkAndNext()
598598
freeSpecial(special, unsafe.Pointer(p), size)
599599
}

src/runtime/mheap.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ func (h *mheap) initSpan(s *mspan, typ spanAllocType, spanclass spanClass, base,
14881488
s.allocBits = newAllocBits(uintptr(s.nelems))
14891489

14901490
// Adjust s.limit down to the object-containing part of the span.
1491-
s.limit = s.base() + uintptr(s.elemsize)*uintptr(s.nelems)
1491+
s.limit = s.base() + s.elemsize*uintptr(s.nelems)
14921492

14931493
// It's safe to access h.sweepgen without the heap lock because it's
14941494
// only ever updated with the world stopped and we run on the
@@ -2152,11 +2152,11 @@ func (span *mspan) specialFindSplicePoint(offset uintptr, kind byte) (**special,
21522152
if s == nil {
21532153
break
21542154
}
2155-
if offset == uintptr(s.offset) && kind == s.kind {
2155+
if offset == s.offset && kind == s.kind {
21562156
found = true
21572157
break
21582158
}
2159-
if offset < uintptr(s.offset) || (offset == uintptr(s.offset) && kind < s.kind) {
2159+
if offset < s.offset || (offset == s.offset && kind < s.kind) {
21602160
break
21612161
}
21622162
iter = &s.next
@@ -2323,14 +2323,14 @@ func getCleanupContext(ptr uintptr, cleanupID uint64) *specialCheckFinalizer {
23232323
// Reached the end of the linked list. Stop searching at this point.
23242324
break
23252325
}
2326-
if offset == uintptr(s.offset) && _KindSpecialCheckFinalizer == s.kind &&
2326+
if offset == s.offset && _KindSpecialCheckFinalizer == s.kind &&
23272327
(*specialCheckFinalizer)(unsafe.Pointer(s)).cleanupID == cleanupID {
23282328
// The special is a cleanup and contains a matching cleanup id.
23292329
*iter = s.next
23302330
found = (*specialCheckFinalizer)(unsafe.Pointer(s))
23312331
break
23322332
}
2333-
if offset < uintptr(s.offset) || (offset == uintptr(s.offset) && _KindSpecialCheckFinalizer < s.kind) {
2333+
if offset < s.offset || (offset == s.offset && _KindSpecialCheckFinalizer < s.kind) {
23342334
// The special is outside the region specified for that kind of
23352335
// special. The specials are sorted by kind.
23362336
break
@@ -2373,14 +2373,14 @@ func clearCleanupContext(ptr uintptr, cleanupID uint64) {
23732373
// Reached the end of the linked list. Stop searching at this point.
23742374
break
23752375
}
2376-
if offset == uintptr(s.offset) && _KindSpecialCheckFinalizer == s.kind &&
2376+
if offset == s.offset && _KindSpecialCheckFinalizer == s.kind &&
23772377
(*specialCheckFinalizer)(unsafe.Pointer(s)).cleanupID == cleanupID {
23782378
// The special is a cleanup and contains a matching cleanup id.
23792379
*iter = s.next
23802380
found = s
23812381
break
23822382
}
2383-
if offset < uintptr(s.offset) || (offset == uintptr(s.offset) && _KindSpecialCheckFinalizer < s.kind) {
2383+
if offset < s.offset || (offset == s.offset && _KindSpecialCheckFinalizer < s.kind) {
23842384
// The special is outside the region specified for that kind of
23852385
// special. The specials are sorted by kind.
23862386
break
@@ -2476,7 +2476,7 @@ type specialWeakHandle struct {
24762476

24772477
//go:linkname internal_weak_runtime_registerWeakPointer weak.runtime_registerWeakPointer
24782478
func internal_weak_runtime_registerWeakPointer(p unsafe.Pointer) unsafe.Pointer {
2479-
return unsafe.Pointer(getOrAddWeakHandle(unsafe.Pointer(p)))
2479+
return unsafe.Pointer(getOrAddWeakHandle(p))
24802480
}
24812481

24822482
//go:linkname internal_weak_runtime_makeStrongFromWeak weak.runtime_makeStrongFromWeak

src/runtime/slice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,5 +397,5 @@ func bytealg_MakeNoZero(len int) []byte {
397397
panicmakeslicelen()
398398
}
399399
cap := roundupsize(uintptr(len), true)
400-
return unsafe.Slice((*byte)(mallocgc(uintptr(cap), nil, false)), cap)[:len]
400+
return unsafe.Slice((*byte)(mallocgc(cap, nil, false)), cap)[:len]
401401
}

0 commit comments

Comments
 (0)