Skip to content

Commit edec337

Browse files
committed
http/httpguts: eliminate bounds checks in IsTokenRune
1 parent 58dbc95 commit edec337

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

http/httpguts/httplex.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"golang.org/x/net/idna"
1313
)
1414

15-
var isTokenTable = [127]bool{
15+
var isTokenTable = [256]bool{
1616
'!': true,
1717
'#': true,
1818
'$': true,
@@ -93,8 +93,7 @@ var isTokenTable = [127]bool{
9393
}
9494

9595
func IsTokenRune(r rune) bool {
96-
i := int(r)
97-
return i < len(isTokenTable) && isTokenTable[i]
96+
return r < utf8.RuneSelf && isTokenTable[byte(r)]
9897
}
9998

10099
// HeaderValuesContainsToken reports whether any string in values

0 commit comments

Comments
 (0)