Optimizes tree lookup

This commit is contained in:
Manu Mtz-Almeida
2015-05-29 21:03:28 +02:00
parent 9584e4ea5c
commit 66e9feb622
2 changed files with 43 additions and 20 deletions

16
tree.go
View File

@ -36,6 +36,22 @@ func (ps Params) ByName(name string) (va string) {
return
}
type methodTree struct {
method string
root *node
}
type methodTrees []methodTree
func (trees methodTrees) get(method string) *node {
for _, tree := range trees {
if tree.method == method {
return tree.root
}
}
return nil
}
func min(a, b int) int {
if a <= b {
return a