summaryrefslogtreecommitdiff
path: root/src/pkg/strings/strings.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-09-15 09:41:59 -0700
committerRuss Cox <rsc@golang.org>2009-09-15 09:41:59 -0700
commit0ebfa231d21b255d84cfdb8a618cfe397db6c497 (patch)
tree46eac6aefe26f0b9056bff646d960bcba3d076cf /src/pkg/strings/strings.go
parentc67478eb2cfefebf09d0c648efa24bb9578078ba (diff)
downloadgolang-0ebfa231d21b255d84cfdb8a618cfe397db6c497.tar.gz
more "declared and not used".
the last round omitted := range and only checked 1 out of N vars in a multi-var := R=r OCL=34624 CL=34638
Diffstat (limited to 'src/pkg/strings/strings.go')
-rw-r--r--src/pkg/strings/strings.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/pkg/strings/strings.go b/src/pkg/strings/strings.go
index f0f076157..4883d392c 100644
--- a/src/pkg/strings/strings.go
+++ b/src/pkg/strings/strings.go
@@ -157,7 +157,7 @@ func Map(mapping func(rune int) int, s string) string {
maxbytes := len(s); // length of b
nbytes := 0; // number of bytes encoded in b
b := make([]byte, maxbytes);
- for i, c := range s {
+ for _, c := range s {
rune := mapping(c);
wid := 1;
if rune >= utf8.RuneSelf {
@@ -196,8 +196,8 @@ func Title(s string) string {
// removed, as defined by Unicode.
func TrimSpace(s string) string {
start, end := 0, len(s);
- for wid := 0; start < end; start += wid {
- wid = 1;
+ for start < end {
+ wid := 1;
rune := int(s[start]);
if rune >= utf8.RuneSelf {
rune, wid = utf8.DecodeRuneInString(s[start:end])
@@ -205,9 +205,10 @@ func TrimSpace(s string) string {
if !unicode.IsSpace(rune) {
break;
}
+ start += wid;
}
- for wid := 0; start < end; end -= wid {
- wid = 1;
+ for start < end {
+ wid := 1;
rune := int(s[end-1]);
if rune >= utf8.RuneSelf {
// Back up carefully looking for beginning of rune. Mustn't pass start.
@@ -221,6 +222,7 @@ func TrimSpace(s string) string {
if !unicode.IsSpace(rune) {
break;
}
+ end -= wid;
}
return s[start:end];
}