mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
strings: use LastIndexByte in LastIndex
Change-Id: I1add1b92f5c2688a99133d90bf9789d770fd9f05 Reviewed-on: https://go-review.googlesource.com/9503 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
09edc5c6ac
commit
cfb8b18e75
2 changed files with 2 additions and 9 deletions
|
|
@ -185,14 +185,7 @@ func LastIndex(s, sep string) int {
|
|||
case n == 0:
|
||||
return len(s)
|
||||
case n == 1:
|
||||
// special case worth making fast
|
||||
c := sep[0]
|
||||
for i := len(s) - 1; i >= 0; i-- {
|
||||
if s[i] == c {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
return LastIndexByte(s, sep[0])
|
||||
case n == len(s):
|
||||
if sep == s {
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue