mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
strings: 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: Iffbc0f2b3332c6e31c7514b5f644b6fe7bdcfe0d Reviewed-on: https://go-review.googlesource.com/65910 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
This commit is contained in:
parent
5db7572ddf
commit
c82ee79247
1 changed files with 26 additions and 30 deletions
|
|
@ -166,7 +166,6 @@ func IndexRune(s string, r rune) int {
|
|||
// IndexAny returns the index of the first instance of any Unicode code point
|
||||
// from chars in s, or -1 if no Unicode code point from chars is present in s.
|
||||
func IndexAny(s, chars string) int {
|
||||
if len(chars) > 0 {
|
||||
if len(s) > 8 {
|
||||
if as, isASCII := makeASCIISet(chars); isASCII {
|
||||
for i := 0; i < len(s); i++ {
|
||||
|
|
@ -184,7 +183,6 @@ func IndexAny(s, chars string) int {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +190,6 @@ func IndexAny(s, chars string) int {
|
|||
// point from chars in s, or -1 if no Unicode code point from chars is
|
||||
// present in s.
|
||||
func LastIndexAny(s, chars string) int {
|
||||
if len(chars) > 0 {
|
||||
if len(s) > 8 {
|
||||
if as, isASCII := makeASCIISet(chars); isASCII {
|
||||
for i := len(s) - 1; i >= 0; i-- {
|
||||
|
|
@ -212,7 +209,6 @@ func LastIndexAny(s, chars string) int {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue