Optimisation

This commit is contained in:
Alexei Anoshenko 2024-12-01 12:30:33 +03:00
parent f632104d49
commit bed6c1bf41
1 changed files with 3 additions and 16 deletions

View File

@ -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