From 0e57ff7eee4ac71d923f970d15889ad4d50f97a9 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Wed, 12 Oct 2022 07:18:26 +0200 Subject: Add generic set type (#21408) This PR adds a generic set type to get rid of maps used as sets. Co-authored-by: wxiaoguang --- modules/notification/ui/ui.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'modules/notification/ui') diff --git a/modules/notification/ui/ui.go b/modules/notification/ui/ui.go index 5e5196a70a..4d96a6b0ed 100644 --- a/modules/notification/ui/ui.go +++ b/modules/notification/ui/ui.go @@ -10,6 +10,7 @@ import ( issues_model "code.gitea.io/gitea/models/issues" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" + "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/notification/base" @@ -123,14 +124,14 @@ func (ns *notificationService) NotifyNewPullRequest(pr *issues_model.PullRequest log.Error("Unable to load issue: %d for pr: %d: Error: %v", pr.IssueID, pr.ID, err) return } - toNotify := make(map[int64]struct{}, 32) + toNotify := make(container.Set[int64], 32) repoWatchers, err := repo_model.GetRepoWatchersIDs(db.DefaultContext, pr.Issue.RepoID) if err != nil { log.Error("GetRepoWatchersIDs: %v", err) return } for _, id := range repoWatchers { - toNotify[id] = struct{}{} + toNotify.Add(id) } issueParticipants, err := issues_model.GetParticipantsIDsByIssueID(pr.IssueID) if err != nil { @@ -138,11 +139,11 @@ func (ns *notificationService) NotifyNewPullRequest(pr *issues_model.PullRequest return } for _, id := range issueParticipants { - toNotify[id] = struct{}{} + toNotify.Add(id) } delete(toNotify, pr.Issue.PosterID) for _, mention := range mentions { - toNotify[mention.ID] = struct{}{} + toNotify.Add(mention.ID) } for receiverID := range toNotify { _ = ns.issueQueue.Push(issueNotificationOpts{ -- cgit v1.2.3