1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00

Optimize: map or slice initialize allocation size / cap (#1965)

This commit is contained in:
jesse.tang
2022-09-09 20:56:23 +08:00
committed by GitHub
parent b037d11c18
commit 9e8a58bf3b
3 changed files with 44 additions and 43 deletions

View File

@@ -3030,11 +3030,11 @@ func (ctx *Context) ReadMultipartRelated() (MultipartRelated, error) {
return result, nil
}
func distinctStrings(values []string) (result []string) {
seen := make(map[string]struct{})
func distinctStrings(values []string) []string {
seen := make(map[string]struct{}, len(values))
result := make([]string, 0, len(values))
for v := range values {
val := values[v]
for _, val := range values {
if _, ok := seen[val]; !ok {
seen[val] = struct{}{}
result = append(result, val)