From 61583d53d595bef7ca190f129bdfe7dae5f06a4f Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 9 Jul 2025 17:29:01 +0200 Subject: [PATCH] refactor(config): simplify SortedOptions Make use of the slices and maps packages instead of doing things by hand, and pre-allocated sortedOptions. --- internal/config/options.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/internal/config/options.go b/internal/config/options.go index 0d70f43d..a01c8170 100644 --- a/internal/config/options.go +++ b/internal/config/options.go @@ -5,8 +5,9 @@ package config // import "miniflux.app/v2/internal/config" import ( "fmt" + "maps" "net/url" - "sort" + "slices" "strings" "time" @@ -782,14 +783,9 @@ func (o *options) SortedOptions(redactSecret bool) []*option { "WEBAUTHN": o.webAuthn, } - keys := make([]string, 0, len(keyValues)) - for key := range keyValues { - keys = append(keys, key) - } - sort.Strings(keys) - - var sortedOptions []*option - for _, key := range keys { + sortedKeys := slices.Sorted(maps.Keys(keyValues)) + var sortedOptions = make([]*option, 0, len(sortedKeys)) + for _, key := range sortedKeys { sortedOptions = append(sortedOptions, &option{Key: key, Value: keyValues[key]}) } return sortedOptions