Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package gin

import (
"bytes"
"net/url"
"strings"
"unicode"
Expand All @@ -14,12 +13,6 @@ import (
"github.com/gin-gonic/gin/internal/bytesconv"
)

var (
strColon = []byte(":")
strStar = []byte("*")
strSlash = []byte("/")
)

// Param is a single URL parameter, consisting of a key and a value.
type Param struct {
Key string
Expand Down Expand Up @@ -85,16 +78,13 @@ func (n *node) addChild(child *node) {
}

func countParams(path string) uint16 {
var n uint16
s := bytesconv.StringToBytes(path)
n += uint16(bytes.Count(s, strColon))
n += uint16(bytes.Count(s, strStar))
return n
colons := strings.Count(path, ":")
stars := strings.Count(path, "*")
return uint16(colons + stars)
}

func countSections(path string) uint16 {
s := bytesconv.StringToBytes(path)
return uint16(bytes.Count(s, strSlash))
return uint16(strings.Count(path, "/"))
}

type nodeType uint8
Expand Down