Skip to content

Commit 500d421

Browse files
committed
net: eliminate bounds checks in hasUpperCase
Function hasUpperCase accesses its parameter's bytes while iterating over its runes. This approach muddles intent and causes an unnecessary bounds check. This CL makes hasUpperCase iterate over its parameter's bytes instead. Updates #76354
1 parent 918644a commit 500d421

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/net/parse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ func xtoi2(s string, e byte) (byte, bool) {
182182

183183
// hasUpperCase tells whether the given string contains at least one upper-case.
184184
func hasUpperCase(s string) bool {
185-
for i := range s {
186-
if 'A' <= s[i] && s[i] <= 'Z' {
185+
for _, b := range []byte(s) {
186+
if 'A' <= b && b <= 'Z' {
187187
return true
188188
}
189189
}

0 commit comments

Comments
 (0)