diff --git a/internal/utils.go b/internal/utils.go index 7a01625..2c59f66 100644 --- a/internal/utils.go +++ b/internal/utils.go @@ -40,18 +40,8 @@ func RandomValue(min, max int) int { return rand.Intn(max-min+1) + min } -// TODO: Optimisation func GetGradientStr(gradientColors []string) string { - gradientStr := "" - last := len(gradientColors) - 1 - for i, hexStr := range gradientColors { - gradientStr += "#" + hexStr - if i != last { - gradientStr += "," - } - } - - return gradientStr + return "#" + strings.Join(gradientColors, ",#") } func GradientExists(gradientToCheck string, gradientsSlice [][]string) bool { diff --git a/server/renderer.go b/server/renderer.go index b7eefab..adef76c 100644 --- a/server/renderer.go +++ b/server/renderer.go @@ -7,6 +7,7 @@ import ( "html/template" "math" "math/rand" + "strings" "time" "github.com/gin-contrib/multitemplate" @@ -38,14 +39,7 @@ func Renderer() multitemplate.Renderer { return show }, "gradientString": func(gradientColors []string) string { - finalString := "" - for i, color := range gradientColors { - finalString += "#" + color - if i != len(gradientColors)-1 { - finalString += "," - } - } - return finalString + return "#" + strings.Join(gradientColors, ",#") }, "isActiveColor": func(color string) bool { activeColor := config.LedActive.Color[0]