Skip to content

Commit ee63bee

Browse files
committed
suggestions from pr
1 parent ad8fe14 commit ee63bee

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

option.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,10 @@ func (optSet *OptionSet) SetDefaults() error {
333333
groupByValue[opt.Value] = append(groupByValue[opt.Value], opt)
334334
}
335335

336+
// Sorts by value source, then a default value being set.
336337
sortOptionByValueSourcePriorityOrDefault := func(a, b *Option) int {
337338
if a.ValueSource != b.ValueSource {
338-
for _, vs := range valueSourcePriority {
339-
if a.ValueSource == vs {
340-
return -1
341-
}
342-
if b.ValueSource == vs {
343-
return 1
344-
}
345-
}
339+
return slices.Index(valueSourcePriority, a.ValueSource) - slices.Index(valueSourcePriority, b.ValueSource)
346340
}
347341
if a.Default != b.Default {
348342
if a.Default == "" {

0 commit comments

Comments
 (0)