mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +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
10 changed files with 306 additions and 299 deletions
|
|
@ -285,38 +285,39 @@ func Fields(s []byte) [][]byte {
|
|||
wasSpace = isSpace
|
||||
}
|
||||
|
||||
if setBits < utf8.RuneSelf { // ASCII fast path
|
||||
a := make([][]byte, n)
|
||||
na := 0
|
||||
fieldStart := 0
|
||||
i := 0
|
||||
// Skip spaces in the front of the input.
|
||||
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
|
||||
i := 0
|
||||
// Skip spaces in the front of the input.
|
||||
for i < len(s) && asciiSpace[s[i]] != 0 {
|
||||
i++
|
||||
}
|
||||
fieldStart = i
|
||||
for i < len(s) {
|
||||
if asciiSpace[s[i]] == 0 {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
a[na] = s[fieldStart:i]
|
||||
na++
|
||||
i++
|
||||
// Skip spaces in between fields.
|
||||
for i < len(s) && asciiSpace[s[i]] != 0 {
|
||||
i++
|
||||
}
|
||||
fieldStart = i
|
||||
for i < len(s) {
|
||||
if asciiSpace[s[i]] == 0 {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
a[na] = s[fieldStart:i]
|
||||
na++
|
||||
i++
|
||||
// Skip spaces in between fields.
|
||||
for i < len(s) && asciiSpace[s[i]] != 0 {
|
||||
i++
|
||||
}
|
||||
fieldStart = i
|
||||
}
|
||||
if fieldStart < len(s) { // Last field might end at EOF.
|
||||
a[na] = s[fieldStart:]
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// Some runes in the input slice are not ASCII.
|
||||
return FieldsFunc(s, unicode.IsSpace)
|
||||
if fieldStart < len(s) { // Last field might end at EOF.
|
||||
a[na] = s[fieldStart:]
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// FieldsFunc interprets s as a sequence of UTF-8-encoded Unicode code points.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue