Skip to content

Commit 6e7487a

Browse files
authored
Update feature_flags.go
use maps and slices instead of explicit for loop
1 parent 5b2ee48 commit 6e7487a

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

internal/configfile/feature_flags.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package configfile
22

3+
import (
4+
"maps"
5+
"slices"
6+
)
7+
38
type flagIota int
49

510
const (
@@ -53,21 +58,12 @@ var knownFlags = map[flagIota]string{
5358

5459
// isFeatureFlagKnown verifies that we understand a feature flag.
5560
func isFeatureFlagKnown(flag string) bool {
56-
for _, knownFlag := range knownFlags {
57-
if knownFlag == flag {
58-
return true
59-
}
60-
}
61-
return false
61+
collection := slices.Collect(maps.Values(knownFlags))
62+
return slices.Contains(collection, flag)
6263
}
6364

6465
// IsFeatureFlagSet returns true if the feature flag "flagWant" is enabled.
6566
func (cf *ConfFile) IsFeatureFlagSet(flagWant flagIota) bool {
6667
flagString := knownFlags[flagWant]
67-
for _, flag := range cf.FeatureFlags {
68-
if flag == flagString {
69-
return true
70-
}
71-
}
72-
return false
68+
return slices.Contains(cf.FeatureFlags, flagString)
7369
}

0 commit comments

Comments
 (0)