Skip to content

Commit

Permalink
refactor(pkg/oomstore): modify FeatureList.GroupIDs()
Browse files Browse the repository at this point in the history
  • Loading branch information
jinghancc committed Jan 14, 2022
1 parent aa2a757 commit 3ce0794
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/oomstore/types/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ func (l FeatureList) Find(find func(*Feature) bool) *Feature {
}

func (l FeatureList) GroupIDs() (ids []int) {
for _, f := range l {
ids = append(ids, f.GroupID)
groupIDMap := make(map[int]struct{})
for _, r := range l {
groupIDMap[r.GroupID] = struct{}{}
}
groupIDs := make([]int, 0, len(groupIDMap))
for id := range groupIDMap {
groupIDs = append(groupIDs, id)
}
return ids
return groupIDs
}

0 comments on commit 3ce0794

Please sign in to comment.