summaryrefslogtreecommitdiff
path: root/src/pkg/strings
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
commitf2b0684d505aaa532ca49ff417e3b2b15e1c4539 (patch)
treec180ce659d13bfc436e9a7b37d79ab8aa3a09601 /src/pkg/strings
parentb36f5ea9726368ea38ae00f88e61710321c9f49f (diff)
downloadgolang-f2b0684d505aaa532ca49ff417e3b2b15e1c4539.tar.gz
strings: remove a couple of redundant tests
(per suggestion from Heresy.Mc@gmail.com) R=rsc CC=golang-dev http://codereview.appspot.com/223052
Diffstat (limited to 'src/pkg/strings')
-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 48d4f0e96..eb2b7e09c 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
}
}