Merge ad38d93dbc3713abbff8db692350a838d64ef3e5 into d3ffc9985281dcf4d3bef604cce4e662b1a327a6

This commit is contained in:
72 2026-04-28 04:21:00 +00:00 committed by GitHub
commit 7dfc73abb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

22
tree.go
View File

@ -130,18 +130,28 @@ func (n *node) incrementChildPrio(pos int) int {
return newPos
}
func (n *node) compareEmptyTree(path string, fullPath string, handlers HandlersChain) {
if len(n.path) == 0 && len(n.children) == 0 {
n.insertChild(path, fullPath, handlers)
n.nType = root
return
}
}
// addRoute adds a node with the given handle to the path.
// Not concurrency-safe!
func (n *node) addRoute(path string, handlers HandlersChain) {
fullPath := path
n.priority++
// Empty tree
if len(n.path) == 0 && len(n.children) == 0 {
n.insertChild(path, fullPath, handlers)
n.nType = root
return
}
// // Empty tree
// if len(n.path) == 0 && len(n.children) == 0 {
// n.insertChild(path, fullPath, handlers)
// n.nType = root
// return
// }
n.compareEmptyTree(path, fullPath, handlers)
parentFullPathIndex := 0