diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-10-12 07:18:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-12 13:18:26 +0800 |
commit | 0e57ff7eee4ac71d923f970d15889ad4d50f97a9 (patch) | |
tree | e5a92c55af5366924bd40ae14b4bf12842239193 /models/repo/repo_list.go | |
parent | e84558b0931309cf1f4f2767bc47296483b9b3e1 (diff) | |
download | gitea-0e57ff7eee4ac71d923f970d15889ad4d50f97a9.tar.gz gitea-0e57ff7eee4ac71d923f970d15889ad4d50f97a9.zip |
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>
Diffstat (limited to 'models/repo/repo_list.go')
-rw-r--r-- | models/repo/repo_list.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/models/repo/repo_list.go b/models/repo/repo_list.go index cc524a417e..0cd0a3c8e3 100644 --- a/models/repo/repo_list.go +++ b/models/repo/repo_list.go @@ -68,10 +68,10 @@ func (repos RepositoryList) loadAttributes(ctx context.Context) error { return nil } - set := make(map[int64]struct{}) + set := make(container.Set[int64]) repoIDs := make([]int64, len(repos)) for i := range repos { - set[repos[i].OwnerID] = struct{}{} + set.Add(repos[i].OwnerID) repoIDs[i] = repos[i].ID } @@ -79,7 +79,7 @@ func (repos RepositoryList) loadAttributes(ctx context.Context) error { users := make(map[int64]*user_model.User, len(set)) if err := db.GetEngine(ctx). Where("id > 0"). - In("id", container.KeysInt64(set)). + In("id", set.Values()). Find(&users); err != nil { return fmt.Errorf("find users: %v", err) } |