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