From 0c3f5d77d9f09b4f87b3a04dfeec8c689fcc3f36 Mon Sep 17 00:00:00 2001 From: thinkerou Date: Wed, 27 Nov 2019 13:09:15 +0800 Subject: [PATCH] use for range --- tree.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tree.go b/tree.go index 41947570..4f1a41a4 100644 --- a/tree.go +++ b/tree.go @@ -64,8 +64,8 @@ func min(a, b int) int { func countParams(path string) uint8 { var n uint - for i := 0; i < len(path); i++ { - if path[i] == ':' || path[i] == '*' { + for _, m := range []byte(path) { + if m == ':' || m == '*' { n++ } } @@ -221,8 +221,8 @@ func (n *node) addRoute(path string, handlers HandlersChain) { } // Check if a child with the next path byte exists - for i := 0; i < len(n.indices); i++ { - if c == n.indices[i] { + for i, m := range []byte(n.indices) { + if m == c { parentFullPathIndex += len(n.path) i = n.incrementChildPrio(i) n = n.children[i]