Skip to content

Commit 1d089a0

Browse files
refactor/gitindex: use maps.Keys for deterministic config key ordering
The helper that sorted config keys manually built an intermediate slice before sorting, even though Go now provides an iterator-first path for this pattern. Using maps.Keys with slices.Sorted keeps the helper shorter and makes the intent explicit while preserving deterministic ordering for clone and config-update command generation. Test Plan: go test ./... Amp-Thread-ID: https://ampcode.com/threads/T-019d0be8-9ecb-7004-acaa-a53513692639 Co-authored-by: Amp <amp@ampcode.com>
1 parent 47e0ba3 commit 1d089a0

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

gitindex/clone_config.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,14 @@ import (
1818
"bytes"
1919
"errors"
2020
"fmt"
21+
"maps"
2122
"os/exec"
22-
"sort"
23+
"slices"
2324
"strings"
2425
)
2526

2627
func sortedKeys(settings map[string]string) []string {
27-
keys := make([]string, 0, len(settings))
28-
for k := range settings {
29-
keys = append(keys, k)
30-
}
31-
sort.Strings(keys)
32-
return keys
28+
return slices.Sorted(maps.Keys(settings))
3329
}
3430

3531
func cloneConfigArgs(settings map[string]string) []string {

0 commit comments

Comments
 (0)