mirror of
https://github.com/golang/go.git
synced 2025-05-19 06:14:40 +00:00
all: unindent some big chunks of code
Found with mvdan.cc/unindent. Prioritized the ones with the biggest wins for now. Change-Id: I2b032e45cdd559fc9ed5b1ee4c4de42c4c92e07b Reviewed-on: https://go-review.googlesource.com/56470 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
b73d46de36
commit
59413d34c9
@ -285,7 +285,12 @@ func Fields(s []byte) [][]byte {
|
||||
wasSpace = isSpace
|
||||
}
|
||||
|
||||
if setBits < utf8.RuneSelf { // ASCII fast path
|
||||
if setBits >= utf8.RuneSelf {
|
||||
// Some runes in the input slice are not ASCII.
|
||||
return FieldsFunc(s, unicode.IsSpace)
|
||||
}
|
||||
|
||||
// ASCII fast path
|
||||
a := make([][]byte, n)
|
||||
na := 0
|
||||
fieldStart := 0
|
||||
@ -313,10 +318,6 @@ func Fields(s []byte) [][]byte {
|
||||
a[na] = s[fieldStart:]
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// Some runes in the input slice are not ASCII.
|
||||
return FieldsFunc(s, unicode.IsSpace)
|
||||
}
|
||||
|
||||
// FieldsFunc interprets s as a sequence of UTF-8-encoded Unicode code points.
|
||||
|
@ -514,7 +514,9 @@ func (d *Data) readType(name string, r typeReader, off Offset, typeCache map[Off
|
||||
var lastFieldType *Type
|
||||
var lastFieldBitOffset int64
|
||||
for kid := next(); kid != nil; kid = next() {
|
||||
if kid.Tag == TagMember {
|
||||
if kid.Tag != TagMember {
|
||||
continue
|
||||
}
|
||||
f := new(StructField)
|
||||
if f.Type = typeOf(kid); err != nil {
|
||||
goto Error
|
||||
@ -556,7 +558,6 @@ func (d *Data) readType(name string, r typeReader, off Offset, typeCache map[Off
|
||||
lastFieldType = &f.Type
|
||||
lastFieldBitOffset = bito
|
||||
}
|
||||
}
|
||||
if t.Kind != "union" {
|
||||
b, ok := e.Val(AttrByteSize).(int64)
|
||||
if ok && b*8 == lastFieldBitOffset {
|
||||
|
@ -1195,7 +1195,9 @@ func (ctxt *Context) shouldBuild(content []byte, allTags map[string]bool, binary
|
||||
p = p[len(p):]
|
||||
}
|
||||
line = bytes.TrimSpace(line)
|
||||
if bytes.HasPrefix(line, slashslash) {
|
||||
if !bytes.HasPrefix(line, slashslash) {
|
||||
continue
|
||||
}
|
||||
if bytes.Equal(line, binaryOnlyComment) {
|
||||
sawBinaryOnly = true
|
||||
}
|
||||
@ -1216,7 +1218,6 @@ func (ctxt *Context) shouldBuild(content []byte, allTags map[string]bool, binary
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if binaryOnly != nil && sawBinaryOnly {
|
||||
*binaryOnly = true
|
||||
|
@ -134,7 +134,10 @@ type getter func(x *operand, i int)
|
||||
// the incoming getter with that i.
|
||||
//
|
||||
func unpack(get getter, n int, allowCommaOk bool) (getter, int, bool) {
|
||||
if n == 1 {
|
||||
if n != 1 {
|
||||
// zero or multiple values
|
||||
return get, n, false
|
||||
}
|
||||
// possibly result of an n-valued function call or comma,ok value
|
||||
var x0 operand
|
||||
get(&x0, 0)
|
||||
@ -171,10 +174,6 @@ func unpack(get getter, n int, allowCommaOk bool) (getter, int, bool) {
|
||||
}
|
||||
*x = x0
|
||||
}, 1, false
|
||||
}
|
||||
|
||||
// zero or multiple values
|
||||
return get, n, false
|
||||
}
|
||||
|
||||
// arguments checks argument passing for the call with the given signature.
|
||||
|
@ -205,7 +205,9 @@ func expm1(x float64) float64 {
|
||||
r1 := 1 + hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5))))
|
||||
t := 3 - r1*hfx
|
||||
e := hxs * ((r1 - t) / (6.0 - x*t))
|
||||
if k != 0 {
|
||||
if k == 0 {
|
||||
return x - (x*e - hxs) // c is 0
|
||||
}
|
||||
e = (x*(e-c) - c)
|
||||
e -= hxs
|
||||
switch {
|
||||
@ -227,11 +229,9 @@ func expm1(x float64) float64 {
|
||||
y = Float64frombits(Float64bits(y) + uint64(k)<<52) // add k to y's exponent
|
||||
return y
|
||||
}
|
||||
t := Float64frombits(uint64(0x3ff-k) << 52) // 2**-k
|
||||
t = Float64frombits(uint64(0x3ff-k) << 52) // 2**-k
|
||||
y := x - (e + t)
|
||||
y++
|
||||
y = Float64frombits(Float64bits(y) + uint64(k)<<52) // add k to y's exponent
|
||||
return y
|
||||
}
|
||||
return x - (x*e - hxs) // c is 0
|
||||
}
|
||||
|
@ -1129,7 +1129,9 @@ func scavengelist(list *mSpanList, now, limit uint64) uintptr {
|
||||
|
||||
var sumreleased uintptr
|
||||
for s := list.first; s != nil; s = s.next {
|
||||
if (now-uint64(s.unusedsince)) > limit && s.npreleased != s.npages {
|
||||
if (now-uint64(s.unusedsince)) <= limit || s.npreleased == s.npages {
|
||||
continue
|
||||
}
|
||||
start := s.base()
|
||||
end := start + s.npages<<_PageShift
|
||||
if physPageSize > _PageSize {
|
||||
@ -1157,7 +1159,6 @@ func scavengelist(list *mSpanList, now, limit uint64) uintptr {
|
||||
s.npreleased = len >> _PageShift
|
||||
sysUnused(unsafe.Pointer(start), len)
|
||||
}
|
||||
}
|
||||
return sumreleased
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,9 @@ func sysargs(argc int32, argv **byte) {
|
||||
|
||||
// now argv+n is auxv
|
||||
auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize))
|
||||
if sysauxv(auxv[:]) == 0 {
|
||||
if sysauxv(auxv[:]) != 0 {
|
||||
return
|
||||
}
|
||||
// In some situations we don't get a loader-provided
|
||||
// auxv, such as when loaded as a library on Android.
|
||||
// Fall back to /proc/self/auxv.
|
||||
@ -237,7 +239,7 @@ func sysargs(argc int32, argv **byte) {
|
||||
return
|
||||
}
|
||||
var buf [128]uintptr
|
||||
n := read(fd, noescape(unsafe.Pointer(&buf[0])), int32(unsafe.Sizeof(buf)))
|
||||
n = read(fd, noescape(unsafe.Pointer(&buf[0])), int32(unsafe.Sizeof(buf)))
|
||||
closefd(fd)
|
||||
if n < 0 {
|
||||
return
|
||||
@ -246,7 +248,6 @@ func sysargs(argc int32, argv **byte) {
|
||||
// the whole file.
|
||||
buf[len(buf)-2] = _AT_NULL
|
||||
sysauxv(buf[:])
|
||||
}
|
||||
}
|
||||
|
||||
func sysauxv(auxv []uintptr) int {
|
||||
|
@ -244,7 +244,9 @@ func freedefer(d *_defer) {
|
||||
freedeferfn()
|
||||
}
|
||||
sc := deferclass(uintptr(d.siz))
|
||||
if sc < uintptr(len(p{}.deferpool)) {
|
||||
if sc >= uintptr(len(p{}.deferpool)) {
|
||||
return
|
||||
}
|
||||
pp := getg().m.p.ptr()
|
||||
if len(pp.deferpool[sc]) == cap(pp.deferpool[sc]) {
|
||||
// Transfer half of local cache to the central cache.
|
||||
@ -273,7 +275,6 @@ func freedefer(d *_defer) {
|
||||
}
|
||||
*d = _defer{}
|
||||
pp.deferpool[sc] = append(pp.deferpool[sc], d)
|
||||
}
|
||||
}
|
||||
|
||||
// Separate function so that it can split stack.
|
||||
|
@ -578,7 +578,9 @@ func adjustpointers(scanp unsafe.Pointer, cbv *bitvector, adjinfo *adjustinfo, f
|
||||
if stackDebug >= 4 {
|
||||
print(" ", add(scanp, i*sys.PtrSize), ":", ptrnames[ptrbit(&bv, i)], ":", hex(*(*uintptr)(add(scanp, i*sys.PtrSize))), " # ", i, " ", bv.bytedata[i/8], "\n")
|
||||
}
|
||||
if ptrbit(&bv, i) == 1 {
|
||||
if ptrbit(&bv, i) != 1 {
|
||||
continue
|
||||
}
|
||||
pp := (*uintptr)(add(scanp, i*sys.PtrSize))
|
||||
retry:
|
||||
p := *pp
|
||||
@ -603,7 +605,6 @@ func adjustpointers(scanp unsafe.Pointer, cbv *bitvector, adjinfo *adjustinfo, f
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Note: the argument/return area is adjusted by the callee.
|
||||
|
@ -333,7 +333,9 @@ func (b *Writer) format(pos0 int, line0, line1 int) (pos int) {
|
||||
for this := line0; this < line1; this++ {
|
||||
line := b.lines[this]
|
||||
|
||||
if column < len(line)-1 {
|
||||
if column >= len(line)-1 {
|
||||
continue
|
||||
}
|
||||
// cell exists in this column => this line
|
||||
// has more cells than the previous line
|
||||
// (the last cell per line is ignored because cells are
|
||||
@ -379,7 +381,6 @@ func (b *Writer) format(pos0 int, line0, line1 int) (pos int) {
|
||||
b.widths = b.widths[0 : len(b.widths)-1] // pop width
|
||||
line0 = this
|
||||
}
|
||||
}
|
||||
|
||||
// print unprinted lines until end
|
||||
return b.writeLines(pos, line0, line1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user