aboutsummaryrefslogtreecommitdiffstats
path: root/routers
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 /routers
parent815d267c8031daa19b82b291a6393a54715567c0 (diff)
downloadgitea-5315153059529f03b06c8f25487ffcc21ae3163f.tar.gz
gitea-5315153059529f03b06c8f25487ffcc21ae3163f.zip
Use `Set[Type]` instead of `map[Type]bool/struct{}`. (#26804)
Diffstat (limited to 'routers')
-rw-r--r--routers/api/actions/runner/utils.go8
-rw-r--r--routers/web/user/home.go7
2 files changed, 5 insertions, 10 deletions
diff --git a/routers/api/actions/runner/utils.go b/routers/api/actions/runner/utils.go
index b8c7ca842a..24432ab6b2 100644
--- a/routers/api/actions/runner/utils.go
+++ b/routers/api/actions/runner/utils.go
@@ -10,6 +10,7 @@ import (
actions_model "code.gitea.io/gitea/models/actions"
secret_model "code.gitea.io/gitea/models/secret"
actions_module "code.gitea.io/gitea/modules/actions"
+ "code.gitea.io/gitea/modules/container"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
@@ -197,10 +198,7 @@ func findTaskNeeds(ctx context.Context, task *actions_model.ActionTask) (map[str
if len(task.Job.Needs) == 0 {
return nil, nil
}
- needs := map[string]struct{}{}
- for _, v := range task.Job.Needs {
- needs[v] = struct{}{}
- }
+ needs := container.SetOf(task.Job.Needs...)
jobs, _, err := actions_model.FindRunJobs(ctx, actions_model.FindRunJobOptions{RunID: task.Job.RunID})
if err != nil {
@@ -209,7 +207,7 @@ func findTaskNeeds(ctx context.Context, task *actions_model.ActionTask) (map[str
ret := make(map[string]*runnerv1.TaskNeed, len(needs))
for _, job := range jobs {
- if _, ok := needs[job.JobID]; !ok {
+ if !needs.Contains(job.JobID) {
continue
}
if job.TaskID == 0 || !job.Status.IsDone() {
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index c44e5a50af..a7f6a52f1b 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -567,12 +567,9 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
// Remove repositories that should not be shown,
// which are repositories that have no issues and are not selected by the user.
- selectedReposMap := make(map[int64]struct{}, len(selectedRepoIDs))
- for _, repoID := range selectedRepoIDs {
- selectedReposMap[repoID] = struct{}{}
- }
+ selectedRepos := container.SetOf(selectedRepoIDs...)
for k, v := range issueCountByRepo {
- if _, ok := selectedReposMap[k]; !ok && v == 0 {
+ if v == 0 && !selectedRepos.Contains(k) {
delete(issueCountByRepo, k)
}
}