File tree Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Original file line number Diff line number Diff line change 55package gin
66
77import (
8- "bytes"
98 "net/url"
109 "strings"
1110 "unicode"
@@ -14,12 +13,6 @@ import (
1413 "github.com/gin-gonic/gin/internal/bytesconv"
1514)
1615
17- var (
18- strColon = []byte (":" )
19- strStar = []byte ("*" )
20- strSlash = []byte ("/" )
21- )
22-
2316// Param is a single URL parameter, consisting of a key and a value.
2417type Param struct {
2518 Key string
@@ -85,16 +78,13 @@ func (n *node) addChild(child *node) {
8578}
8679
8780func countParams (path string ) uint16 {
88- var n uint16
89- s := bytesconv .StringToBytes (path )
90- n += uint16 (bytes .Count (s , strColon ))
91- n += uint16 (bytes .Count (s , strStar ))
92- return n
81+ colons := strings .Count (path , ":" )
82+ stars := strings .Count (path , "*" )
83+ return uint16 (colons + stars )
9384}
9485
9586func countSections (path string ) uint16 {
96- s := bytesconv .StringToBytes (path )
97- return uint16 (bytes .Count (s , strSlash ))
87+ return uint16 (strings .Count (path , "/" ))
9888}
9989
10090type nodeType uint8
You can’t perform that action at this time.
0 commit comments