From bed6c1bf41021af9274341137126173c8f7ee4dd Mon Sep 17 00:00:00 2001 From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com> Date: Sun, 1 Dec 2024 12:30:33 +0300 Subject: [PATCH] Optimisation --- viewUtils.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/viewUtils.go b/viewUtils.go index f1ea069..4bf5242 100644 --- a/viewUtils.go +++ b/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('/') + if view = ViewByID(view, id); view == nil { + return nil } - buffer.WriteString(id) } } - view = ViewByID(view, buffer.String()) } return view