mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-16 15:02:43 +00:00
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 (
|
|||
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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue