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 /routers/web/repo/lfs.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 'routers/web/repo/lfs.go')
-rw-r--r-- | routers/web/repo/lfs.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/routers/web/repo/lfs.go b/routers/web/repo/lfs.go index baec48bfea..633b8ab1a5 100644 --- a/routers/web/repo/lfs.go +++ b/routers/web/repo/lfs.go @@ -18,6 +18,7 @@ import ( git_model "code.gitea.io/gitea/models/git" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/charset" + "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/git/pipeline" @@ -176,14 +177,12 @@ func LFSLocks(ctx *context.Context) { return } - filemap := make(map[string]bool, len(filelist)) - for _, name := range filelist { - filemap[name] = true - } + fileset := make(container.Set[string], len(filelist)) + fileset.AddMultiple(filelist...) linkable := make([]bool, len(lfsLocks)) for i, lock := range lfsLocks { - linkable[i] = filemap[lock.Path] + linkable[i] = fileset.Contains(lock.Path) } ctx.Data["Linkable"] = linkable |