aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2010-02-25 10:02:39 -0800
committerRobert Griesemer <gri@golang.org>2010-02-25 10:02:39 -0800
commit859e4d51c30dce31eaa0d11ad1477a5465a194e7 (patch)
treea24a9f4f5e3c0b7ec3003d8ed5db7da29d80c15d
parent20834d644f72a327b440cb76120f020c98297024 (diff)
downloadgo-859e4d51c30dce31eaa0d11ad1477a5465a194e7.tar.gz
go-859e4d51c30dce31eaa0d11ad1477a5465a194e7.zip
strings: remove a couple of redundant tests
(per suggestion from Heresy.Mc@gmail.com) R=rsc CC=golang-dev https://golang.org/cl/223052
-rw-r--r--src/pkg/strings/strings.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pkg/strings/strings.go b/src/pkg/strings/strings.go
index 48d4f0e96a..eb2b7e09c6 100644
--- a/src/pkg/strings/strings.go
+++ b/src/pkg/strings/strings.go
@@ -65,8 +65,9 @@ func Index(s, sep string) int {
}
return -1
}
+ // n > 1
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
}
}
@@ -89,8 +90,9 @@ func LastIndex(s, sep string) int {
}
return -1
}
+ // n > 1
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
}
}