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
|
@ -20,6 +20,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/git"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
@ -640,7 +641,7 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequ
|
|||
|
||||
posterSig := pr.Issue.Poster.NewGitSig().String()
|
||||
|
||||
authorsMap := map[string]bool{}
|
||||
uniqueAuthors := make(container.Set[string])
|
||||
authors := make([]string, 0, len(commits))
|
||||
stringBuilder := strings.Builder{}
|
||||
|
||||
|
@ -687,9 +688,8 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequ
|
|||
}
|
||||
|
||||
authorString := commit.Author.String()
|
||||
if !authorsMap[authorString] && authorString != posterSig {
|
||||
if uniqueAuthors.Add(authorString) && authorString != posterSig {
|
||||
authors = append(authors, authorString)
|
||||
authorsMap[authorString] = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -709,9 +709,8 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequ
|
|||
}
|
||||
for _, commit := range commits {
|
||||
authorString := commit.Author.String()
|
||||
if !authorsMap[authorString] && authorString != posterSig {
|
||||
if uniqueAuthors.Add(authorString) && authorString != posterSig {
|
||||
authors = append(authors, authorString)
|
||||
authorsMap[authorString] = true
|
||||
}
|
||||
}
|
||||
skip += limit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue