mirror of https://github.com/anoshenko/rui.git
Optimisation
This commit is contained in:
parent
f632104d49
commit
bed6c1bf41
19
viewUtils.go
19
viewUtils.go
|
@ -71,27 +71,14 @@ func SetParams(rootView View, viewID string, params Params) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSubview(view View, subviewID []string) View {
|
func getSubview(view View, subviewID []string) View {
|
||||||
switch len(subviewID) {
|
if view != nil {
|
||||||
case 0:
|
|
||||||
// do nothing
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
if subviewID[0] != "" {
|
|
||||||
view = ViewByID(view, subviewID[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
buffer := allocStringBuilder()
|
|
||||||
defer freeStringBuilder(buffer)
|
|
||||||
for _, id := range subviewID {
|
for _, id := range subviewID {
|
||||||
if id != "" {
|
if id != "" {
|
||||||
if buffer.Len() > 0 {
|
if view = ViewByID(view, id); view == nil {
|
||||||
buffer.WriteRune('/')
|
return nil
|
||||||
}
|
}
|
||||||
buffer.WriteString(id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view = ViewByID(view, buffer.String())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return view
|
return view
|
||||||
|
|
Loading…
Reference in New Issue