mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-19 15:57:48 +08:00
use for range
This commit is contained in:
parent
231ff00d1f
commit
0c3f5d77d9
8
tree.go
8
tree.go
@ -64,8 +64,8 @@ func min(a, b int) int {
|
|||||||
|
|
||||||
func countParams(path string) uint8 {
|
func countParams(path string) uint8 {
|
||||||
var n uint
|
var n uint
|
||||||
for i := 0; i < len(path); i++ {
|
for _, m := range []byte(path) {
|
||||||
if path[i] == ':' || path[i] == '*' {
|
if m == ':' || m == '*' {
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,8 +221,8 @@ func (n *node) addRoute(path string, handlers HandlersChain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if a child with the next path byte exists
|
// Check if a child with the next path byte exists
|
||||||
for i := 0; i < len(n.indices); i++ {
|
for i, m := range []byte(n.indices) {
|
||||||
if c == n.indices[i] {
|
if m == c {
|
||||||
parentFullPathIndex += len(n.path)
|
parentFullPathIndex += len(n.path)
|
||||||
i = n.incrementChildPrio(i)
|
i = n.incrementChildPrio(i)
|
||||||
n = n.children[i]
|
n = n.children[i]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user