mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +00:00
Use Set[Type]
instead of map[Type]bool/struct{}
. (#26804)
This commit is contained in:
parent
815d267c80
commit
5315153059
9 changed files with 36 additions and 48 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models/perm"
|
||||
"code.gitea.io/gitea/modules/container"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
)
|
||||
|
@ -318,14 +319,13 @@ var (
|
|||
|
||||
// FindUnitTypes give the unit key names and return valid unique units and invalid keys
|
||||
func FindUnitTypes(nameKeys ...string) (res []Type, invalidKeys []string) {
|
||||
m := map[Type]struct{}{}
|
||||
m := make(container.Set[Type])
|
||||
for _, key := range nameKeys {
|
||||
t := TypeFromKey(key)
|
||||
if t == TypeInvalid {
|
||||
invalidKeys = append(invalidKeys, key)
|
||||
} else if _, ok := m[t]; !ok {
|
||||
} else if m.Add(t) {
|
||||
res = append(res, t)
|
||||
m[t] = struct{}{}
|
||||
}
|
||||
}
|
||||
return res, invalidKeys
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue