diff options
| author | David du Colombier <0intro@gmail.com> | 2013-12-17 16:32:27 -0800 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2013-12-17 16:32:27 -0800 |
| commit | bccf029fc09c4b993f6a638b16c5fe33f0102828 (patch) | |
| tree | a7f3f472eaa1ec7b9f8a022797d7c37634dae788 /src | |
| parent | 9aae6c1a8b61af33f766e9a735c04b6afa255160 (diff) | |
| download | go-bccf029fc09c4b993f6a638b16c5fe33f0102828.tar.xz | |
net: rewrite toLower more clearly
Rob suggested this change.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/43670044
Diffstat (limited to 'src')
| -rw-r--r-- | src/pkg/net/lookup_plan9.go | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/pkg/net/lookup_plan9.go b/src/pkg/net/lookup_plan9.go index 8003d177d0..a755ff2aac 100644 --- a/src/pkg/net/lookup_plan9.go +++ b/src/pkg/net/lookup_plan9.go @@ -73,23 +73,21 @@ func queryDNS(addr string, typ string) (res []string, err error) { // ASCII is sufficient to handle the IP protocol names and allow // us to not depend on the strings and unicode packages. func toLower(in string) string { - isAlreadyLowerCase := true for _, c := range in { if 'A' <= c && c <= 'Z' { - isAlreadyLowerCase = false - break - } - } - if isAlreadyLowerCase { - return in - } - out := []byte(in) - for i, c := range out { - if 'A' <= c && c <= 'Z' { - out[i] += 'a' - 'A' + // Has upper case; need to fix. + out := []byte(in) + for i := 0; i < len(in); i++ { + c := in[i] + if 'A' <= c && c <= 'Z' { + c += 'a' - 'A' + } + out[i] = c + } + return string(out) } } - return string(out) + return in } // lookupProtocol looks up IP protocol name and returns |
