Add generic set type (#21408)
This PR adds a generic set type to get rid of maps used as sets. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
e84558b093
commit
0e57ff7eee
41 changed files with 328 additions and 324 deletions
|
@ -18,6 +18,7 @@ import (
|
|||
access_model "code.gitea.io/gitea/models/perm/access"
|
||||
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/log"
|
||||
"code.gitea.io/gitea/modules/references"
|
||||
"code.gitea.io/gitea/modules/repository"
|
||||
|
@ -111,7 +112,7 @@ func UpdateIssuesCommit(doer *user_model.User, repo *repo_model.Repository, comm
|
|||
Action references.XRefAction
|
||||
}
|
||||
|
||||
refMarked := make(map[markKey]bool)
|
||||
refMarked := make(container.Set[markKey])
|
||||
var refRepo *repo_model.Repository
|
||||
var refIssue *issues_model.Issue
|
||||
var err error
|
||||
|
@ -144,10 +145,9 @@ func UpdateIssuesCommit(doer *user_model.User, repo *repo_model.Repository, comm
|
|||
}
|
||||
|
||||
key := markKey{ID: refIssue.ID, Action: ref.Action}
|
||||
if refMarked[key] {
|
||||
if !refMarked.Add(key) {
|
||||
continue
|
||||
}
|
||||
refMarked[key] = true
|
||||
|
||||
// FIXME: this kind of condition is all over the code, it should be consolidated in a single place
|
||||
canclose := perm.IsAdmin() || perm.IsOwner() || perm.CanWriteIssuesOrPulls(refIssue.IsPull) || refIssue.PosterID == doer.ID
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue