mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
strings: unindent Fields
CL 56470 unindented bytes.Fields, but not strings.Fields. Do so now to make it easier to diff the two functions for potential differences. Change-Id: Ifef81f50cee64e8277e91efa5ec5521d8d21d3bd Reviewed-on: https://go-review.googlesource.com/c/go/+/170951 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
20995f6274
commit
f70d457a36
1 changed files with 27 additions and 27 deletions
|
|
@ -341,7 +341,11 @@ func Fields(s string) []string {
|
||||||
wasSpace = isSpace
|
wasSpace = isSpace
|
||||||
}
|
}
|
||||||
|
|
||||||
if setBits < utf8.RuneSelf { // ASCII fast path
|
if setBits >= utf8.RuneSelf {
|
||||||
|
// Some runes in the input string are not ASCII.
|
||||||
|
return FieldsFunc(s, unicode.IsSpace)
|
||||||
|
}
|
||||||
|
// ASCII fast path
|
||||||
a := make([]string, n)
|
a := make([]string, n)
|
||||||
na := 0
|
na := 0
|
||||||
fieldStart := 0
|
fieldStart := 0
|
||||||
|
|
@ -371,10 +375,6 @@ func Fields(s string) []string {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some runes in the input string are not ASCII.
|
|
||||||
return FieldsFunc(s, unicode.IsSpace)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FieldsFunc splits the string s at each run of Unicode code points c satisfying f(c)
|
// FieldsFunc splits the string s at each run of Unicode code points c satisfying f(c)
|
||||||
// and returns an array of slices of s. If all code points in s satisfy f(c) or the
|
// and returns an array of slices of s. If all code points in s satisfy f(c) or the
|
||||||
// string is empty, an empty slice is returned.
|
// string is empty, an empty slice is returned.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue