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
|
@ -11,6 +11,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/container"
|
||||
"code.gitea.io/gitea/modules/httpcache"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
@ -83,11 +84,11 @@ func AssetsHandlerFunc(opts *Options) http.HandlerFunc {
|
|||
}
|
||||
|
||||
// parseAcceptEncoding parse Accept-Encoding: deflate, gzip;q=1.0, *;q=0.5 as compress methods
|
||||
func parseAcceptEncoding(val string) map[string]bool {
|
||||
func parseAcceptEncoding(val string) container.Set[string] {
|
||||
parts := strings.Split(val, ";")
|
||||
types := make(map[string]bool)
|
||||
types := make(container.Set[string])
|
||||
for _, v := range strings.Split(parts[0], ",") {
|
||||
types[strings.TrimSpace(v)] = true
|
||||
types.Add(strings.TrimSpace(v))
|
||||
}
|
||||
return types
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue