diff options
Diffstat (limited to 'models/repo/topic.go')
-rw-r--r-- | models/repo/topic.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/models/repo/topic.go b/models/repo/topic.go index 2a16467215..7ba9a49e89 100644 --- a/models/repo/topic.go +++ b/models/repo/topic.go @@ -11,6 +11,7 @@ import ( "strings" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/timeutil" "xorm.io/builder" @@ -62,7 +63,7 @@ func ValidateTopic(topic string) bool { // SanitizeAndValidateTopics sanitizes and checks an array or topics func SanitizeAndValidateTopics(topics []string) (validTopics, invalidTopics []string) { validTopics = make([]string, 0) - mValidTopics := make(map[string]struct{}) + mValidTopics := make(container.Set[string]) invalidTopics = make([]string, 0) for _, topic := range topics { @@ -72,12 +73,12 @@ func SanitizeAndValidateTopics(topics []string) (validTopics, invalidTopics []st continue } // ignore same topic twice - if _, ok := mValidTopics[topic]; ok { + if mValidTopics.Contains(topic) { continue } if ValidateTopic(topic) { validTopics = append(validTopics, topic) - mValidTopics[topic] = struct{}{} + mValidTopics.Add(topic) } else { invalidTopics = append(invalidTopics, topic) } |