mirror of
https://github.com/golang/go
synced 2024-11-25 06:07:58 -07:00
strings: remove a couple of redundant tests
(per suggestion from Heresy.Mc@gmail.com) R=rsc CC=golang-dev https://golang.org/cl/223052
This commit is contained in:
parent
20834d644f
commit
859e4d51c3
@ -65,8 +65,9 @@ func Index(s, sep string) int {
|
|||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
// n > 1
|
||||||
for i := 0; i+n <= len(s); i++ {
|
for i := 0; i+n <= len(s); i++ {
|
||||||
if s[i] == c && (n == 1 || s[i:i+n] == sep) {
|
if s[i] == c && s[i:i+n] == sep {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,8 +90,9 @@ func LastIndex(s, sep string) int {
|
|||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
// n > 1
|
||||||
for i := len(s) - n; i >= 0; i-- {
|
for i := len(s) - n; i >= 0; i-- {
|
||||||
if s[i] == c && (n == 1 || s[i:i+n] == sep) {
|
if s[i] == c && s[i:i+n] == sep {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user