aboutsummaryrefslogtreecommitdiff
path: root/src/strings
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2019-04-09 08:35:36 +0200
committerTobias Klauser <tobias.klauser@gmail.com>2019-04-09 13:57:16 +0000
commit78175474c4a93c2b18516d2127a160b83926c143 (patch)
treed56db1763a9b7a7e1878a5d316009b73326a0527 /src/strings
parent4166ff42c09cae4ca9e15154627e7cfc80586c65 (diff)
downloadgo-78175474c4a93c2b18516d2127a160b83926c143.tar.gz
go-78175474c4a93c2b18516d2127a160b83926c143.zip
strings: use Go style character range comparison in ToUpper/ToLower
As noted by Brad in CL 170954 for package bytes. Change-Id: I2772a356299e54ba5b7884d537e6649039adb9be Reviewed-on: https://go-review.googlesource.com/c/go/+/171198 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/strings')
-rw-r--r--src/strings/strings.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/strings/strings.go b/src/strings/strings.go
index 5a126a7a19..1805a14bd2 100644
--- a/src/strings/strings.go
+++ b/src/strings/strings.go
@@ -559,7 +559,7 @@ func ToUpper(s string) string {
isASCII = false
break
}
- hasLower = hasLower || (c >= 'a' && c <= 'z')
+ hasLower = hasLower || ('a' <= c && c <= 'z')
}
if isASCII { // optimize for ASCII-only strings.
@@ -570,7 +570,7 @@ func ToUpper(s string) string {
b.Grow(len(s))
for i := 0; i < len(s); i++ {
c := s[i]
- if c >= 'a' && c <= 'z' {
+ if 'a' <= c && c <= 'z' {
c -= 'a' - 'A'
}
b.WriteByte(c)
@@ -589,7 +589,7 @@ func ToLower(s string) string {
isASCII = false
break
}
- hasUpper = hasUpper || (c >= 'A' && c <= 'Z')
+ hasUpper = hasUpper || ('A' <= c && c <= 'Z')
}
if isASCII { // optimize for ASCII-only strings.
@@ -600,7 +600,7 @@ func ToLower(s string) string {
b.Grow(len(s))
for i := 0; i < len(s); i++ {
c := s[i]
- if c >= 'A' && c <= 'Z' {
+ if 'A' <= c && c <= 'Z' {
c += 'a' - 'A'
}
b.WriteByte(c)