summaryrefslogtreecommitdiffstats
path: root/models/unit
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-08-30 08:55:25 +0200
committerGitHub <noreply@github.com>2023-08-30 06:55:25 +0000
commit5315153059529f03b06c8f25487ffcc21ae3163f (patch)
treeb5f90daf2f1916f37656369865706d95872a7ae7 /models/unit
parent815d267c8031daa19b82b291a6393a54715567c0 (diff)
downloadgitea-5315153059529f03b06c8f25487ffcc21ae3163f.tar.gz
gitea-5315153059529f03b06c8f25487ffcc21ae3163f.zip
Use `Set[Type]` instead of `map[Type]bool/struct{}`. (#26804)
Diffstat (limited to 'models/unit')
-rw-r--r--models/unit/unit.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/models/unit/unit.go b/models/unit/unit.go
index 5f5e20de1e..ca3e7f999d 100644
--- a/models/unit/unit.go
+++ b/models/unit/unit.go
@@ -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