mirror of
https://github.com/golang/go
synced 2024-11-20 05:44:44 -07:00
bytes: improve readability of IndexAny and LastIndexAny functions
This change removes the check of len(chars) > 0 inside the Index and IndexAny functions which was redundant. Change-Id: Ic4bf8b8a37d7f040d3ebd81b4fc45fcb386b639a Reviewed-on: https://go-review.googlesource.com/65851 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
f22ba1f247
commit
b71f39612a
@ -144,7 +144,6 @@ func IndexRune(s []byte, r rune) int {
|
|||||||
// code points in chars. It returns -1 if chars is empty or if there is no code
|
// code points in chars. It returns -1 if chars is empty or if there is no code
|
||||||
// point in common.
|
// point in common.
|
||||||
func IndexAny(s []byte, chars string) int {
|
func IndexAny(s []byte, chars string) int {
|
||||||
if len(chars) > 0 {
|
|
||||||
if len(s) > 8 {
|
if len(s) > 8 {
|
||||||
if as, isASCII := makeASCIISet(chars); isASCII {
|
if as, isASCII := makeASCIISet(chars); isASCII {
|
||||||
for i, c := range s {
|
for i, c := range s {
|
||||||
@ -169,7 +168,6 @@ func IndexAny(s []byte, chars string) int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +176,6 @@ func IndexAny(s []byte, chars string) int {
|
|||||||
// the Unicode code points in chars. It returns -1 if chars is empty or if
|
// the Unicode code points in chars. It returns -1 if chars is empty or if
|
||||||
// there is no code point in common.
|
// there is no code point in common.
|
||||||
func LastIndexAny(s []byte, chars string) int {
|
func LastIndexAny(s []byte, chars string) int {
|
||||||
if len(chars) > 0 {
|
|
||||||
if len(s) > 8 {
|
if len(s) > 8 {
|
||||||
if as, isASCII := makeASCIISet(chars); isASCII {
|
if as, isASCII := makeASCIISet(chars); isASCII {
|
||||||
for i := len(s) - 1; i >= 0; i-- {
|
for i := len(s) - 1; i >= 0; i-- {
|
||||||
@ -198,7 +195,6 @@ func LastIndexAny(s []byte, chars string) int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user