mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
refactor(config): simplify SortedOptions
Make use of the slices and maps packages instead of doing things by hand, and pre-allocated sortedOptions.
This commit is contained in:
parent
7c42e777ec
commit
61583d53d5
1 changed files with 5 additions and 9 deletions
|
@ -5,8 +5,9 @@ package config // import "miniflux.app/v2/internal/config"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"net/url"
|
"net/url"
|
||||||
"sort"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -782,14 +783,9 @@ func (o *options) SortedOptions(redactSecret bool) []*option {
|
||||||
"WEBAUTHN": o.webAuthn,
|
"WEBAUTHN": o.webAuthn,
|
||||||
}
|
}
|
||||||
|
|
||||||
keys := make([]string, 0, len(keyValues))
|
sortedKeys := slices.Sorted(maps.Keys(keyValues))
|
||||||
for key := range keyValues {
|
var sortedOptions = make([]*option, 0, len(sortedKeys))
|
||||||
keys = append(keys, key)
|
for _, key := range sortedKeys {
|
||||||
}
|
|
||||||
sort.Strings(keys)
|
|
||||||
|
|
||||||
var sortedOptions []*option
|
|
||||||
for _, key := range keys {
|
|
||||||
sortedOptions = append(sortedOptions, &option{Key: key, Value: keyValues[key]})
|
sortedOptions = append(sortedOptions, &option{Key: key, Value: keyValues[key]})
|
||||||
}
|
}
|
||||||
return sortedOptions
|
return sortedOptions
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue