From 10c210a383d6bef98dff628cfd6366005850f319 Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Fri, 31 Dec 2021 17:28:18 +0100 Subject: [PATCH] optimize --- internal/piwigo/piwigotools/categories.go | 6 +++--- internal/piwigo/piwigotools/tags.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/piwigo/piwigotools/categories.go b/internal/piwigo/piwigotools/categories.go index 4c0ea34..de50e38 100644 --- a/internal/piwigo/piwigotools/categories.go +++ b/internal/piwigo/piwigotools/categories.go @@ -10,9 +10,9 @@ type Category struct { } func (c *Categories) Names() []string { - names := []string{} - for _, category := range *c { - names = append(names, category.Name) + names := make([]string, len(*c)) + for i, category := range *c { + names[i] = category.Name } return names } diff --git a/internal/piwigo/piwigotools/tags.go b/internal/piwigo/piwigotools/tags.go index 59a3017..f3e1f32 100644 --- a/internal/piwigo/piwigotools/tags.go +++ b/internal/piwigo/piwigotools/tags.go @@ -17,13 +17,13 @@ type Tag struct { } func (c Tags) NamesWithAgeAt(createdAt TimeResult) []string { - names := []string{} - for _, category := range c { + names := make([]string, len(c)) + for i, category := range c { bd := category.Birthdate.AgeAt(createdAt) if bd != "" { - names = append(names, fmt.Sprintf("%s (%s)", category.Name, bd)) + names[i] = fmt.Sprintf("%s (%s)", category.Name, bd) } else { - names = append(names, category.Name) + names[i] = category.Name } } return names