From ac41b9b48645f4ff991e5bf34f6ecb79b7969d12 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 7 May 2020 15:29:28 +0800 Subject: [PATCH] update Signed-off-by: Bo-Yi Wu --- gin.go | 4 ++-- tree.go | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gin.go b/gin.go index 4e72f81d..7c337d23 100644 --- a/gin.go +++ b/gin.go @@ -259,7 +259,7 @@ func (engine *Engine) addRoute(method, path string, handlers HandlersChain) { root := engine.trees.get(method) if root == nil { root = new(node) - root.fullPath = "/" + // root.fullPath = "/" engine.trees = append(engine.trees, methodTree{method: method, root: root}) } root.addRoute(path, handlers) @@ -406,7 +406,7 @@ func (engine *Engine) handleHTTPRequest(c *Context) { if value.handlers != nil { c.handlers = value.handlers c.Params = value.params - c.fullPath = value.fullPath + // c.fullPath = value.fullPath c.Next() c.writermem.WriteHeaderNow() return diff --git a/tree.go b/tree.go index fc024f7b..e9349ea9 100644 --- a/tree.go +++ b/tree.go @@ -103,7 +103,7 @@ type node struct { nType nodeType maxParams uint8 wildChild bool - fullPath string + // fullPath string } // increments priority of the given child and reorders if necessary. @@ -166,7 +166,7 @@ walk: children: n.children, handlers: n.handlers, priority: n.priority - 1, - fullPath: n.fullPath, + // fullPath: n.fullPath, } // Update maxParams (max of all children) @@ -182,7 +182,7 @@ walk: n.path = path[:i] n.handlers = nil n.wildChild = false - n.fullPath = fullPath[:parentFullPathIndex+i] + // n.fullPath = fullPath[:parentFullPathIndex+i] } // Make new node a child of this node @@ -246,7 +246,7 @@ walk: n.indices += string([]byte{c}) child := &node{ maxParams: numParams, - fullPath: fullPath, + // fullPath: fullPath, } n.children = append(n.children, child) n.incrementChildPrio(len(n.indices) - 1) @@ -328,7 +328,7 @@ func (n *node) insertChild(numParams uint8, path string, fullPath string, handle nType: param, path: wildcard, maxParams: numParams, - fullPath: fullPath, + // fullPath: fullPath, } n.children = []*node{child} n = child @@ -343,7 +343,7 @@ func (n *node) insertChild(numParams uint8, path string, fullPath string, handle child := &node{ maxParams: numParams, priority: 1, - fullPath: fullPath, + // fullPath: fullPath, } n.children = []*node{child} n = child @@ -377,7 +377,7 @@ func (n *node) insertChild(numParams uint8, path string, fullPath string, handle wildChild: true, nType: catchAll, maxParams: 1, - fullPath: fullPath, + // fullPath: fullPath, } // update maxParams of the parent node if n.maxParams < 1 { @@ -392,10 +392,10 @@ func (n *node) insertChild(numParams uint8, path string, fullPath string, handle child = &node{ path: path[i:], nType: catchAll, - maxParams: 1, handlers: handlers, priority: 1, - fullPath: fullPath, + maxParams: 1, + // fullPath: fullPath, } n.children = []*node{child} @@ -405,7 +405,7 @@ func (n *node) insertChild(numParams uint8, path string, fullPath string, handle // If no wildcard was found, simply insert the path and handle n.path = path n.handlers = handlers - n.fullPath = fullPath + // n.fullPath = fullPath } // nodeValue holds return values of (*Node).getValue method @@ -413,7 +413,7 @@ type nodeValue struct { handlers HandlersChain params Params tsr bool - fullPath string + // fullPath string } // getValue returns the handle registered with the given path (key). The values of @@ -430,7 +430,7 @@ walk: // Outer loop for walking the tree // We should have reached the node containing the handle. // Check if this node has a handle registered. if value.handlers = n.handlers; value.handlers != nil { - value.fullPath = n.fullPath + // value.fullPath = n.fullPath return } @@ -519,7 +519,7 @@ walk: // Outer loop for walking the tree } if value.handlers = n.handlers; value.handlers != nil { - value.fullPath = n.fullPath + // value.fullPath = n.fullPath return } if len(n.children) == 1 { @@ -548,7 +548,7 @@ walk: // Outer loop for walking the tree } value.handlers = n.handlers - value.fullPath = n.fullPath + // value.fullPath = n.fullPath return default: