optimize nested conditional (#708)

Co-authored-by: heyanfu <heyanfu@kingsoft.com>
master
heyanfu 4 years ago committed by GitHub
parent 94417be018
commit 8998f16054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -97,23 +97,22 @@ func (t *Tree) next(n *node, route string, result *Result) bool {
}
for i := range route {
if route[i] == slash {
if route[i] != slash {
continue
}
token := route[:i]
return n.forEach(func(k string, v *node) bool {
if r := match(k, token); r.found {
if t.next(v, route[i+1:], result) {
r := match(k, token)
if !r.found || !t.next(v, route[i+1:], result) {
return false
}
if r.named {
addParam(result, r.key, r.value)
}
return true
}
}
return false
})
}
}
return n.forEach(func(k string, v *node) bool {
if r := match(k, route); r.found && v.item != nil {

Loading…
Cancel
Save