From 25a5fe41669cfc1238b3a999188a57a83cf076cd Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Sat, 17 Dec 2022 18:08:31 +0100 Subject: [PATCH] Leave allocation capacity guessing to the runtime (#716) --- jsoninfo/marshal.go | 2 +- openapi2/openapi2.go | 4 ++-- openapi2conv/openapi2_conv.go | 2 +- openapi3/content.go | 2 +- openapi3/path_item.go | 2 +- routers/legacy/router.go | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jsoninfo/marshal.go b/jsoninfo/marshal.go index 6e946d877..f2abf7c00 100644 --- a/jsoninfo/marshal.go +++ b/jsoninfo/marshal.go @@ -23,7 +23,7 @@ type ObjectEncoder struct { func NewObjectEncoder() *ObjectEncoder { return &ObjectEncoder{ - result: make(map[string]json.RawMessage, 8), + result: make(map[string]json.RawMessage), } } diff --git a/openapi2/openapi2.go b/openapi2/openapi2.go index dcc5ddb66..430e39851 100644 --- a/openapi2/openapi2.go +++ b/openapi2/openapi2.go @@ -42,7 +42,7 @@ func (doc *T) UnmarshalJSON(data []byte) error { func (doc *T) AddOperation(path string, method string, operation *Operation) { paths := doc.Paths if paths == nil { - paths = make(map[string]*PathItem, 8) + paths = make(map[string]*PathItem) doc.Paths = paths } pathItem := paths[path] @@ -77,7 +77,7 @@ func (pathItem *PathItem) UnmarshalJSON(data []byte) error { } func (pathItem *PathItem) Operations() map[string]*Operation { - operations := make(map[string]*Operation, 8) + operations := make(map[string]*Operation) if v := pathItem.Delete; v != nil { operations[http.MethodDelete] = v } diff --git a/openapi2conv/openapi2_conv.go b/openapi2conv/openapi2_conv.go index 8c082053f..b81e3c2c4 100644 --- a/openapi2conv/openapi2_conv.go +++ b/openapi2conv/openapi2_conv.go @@ -1206,7 +1206,7 @@ func stripNonCustomExtensions(extensions map[string]interface{}) { func addPathExtensions(doc2 *openapi2.T, path string, extensionProps openapi3.ExtensionProps) { paths := doc2.Paths if paths == nil { - paths = make(map[string]*openapi2.PathItem, 8) + paths = make(map[string]*openapi2.PathItem) doc2.Paths = paths } pathItem := paths[path] diff --git a/openapi3/content.go b/openapi3/content.go index 8abd411da..81b070eec 100644 --- a/openapi3/content.go +++ b/openapi3/content.go @@ -10,7 +10,7 @@ import ( type Content map[string]*MediaType func NewContent() Content { - return make(map[string]*MediaType, 4) + return make(map[string]*MediaType) } func NewContentWithSchema(schema *Schema, consumes []string) Content { diff --git a/openapi3/path_item.go b/openapi3/path_item.go index db83a0a5a..5323dc163 100644 --- a/openapi3/path_item.go +++ b/openapi3/path_item.go @@ -41,7 +41,7 @@ func (pathItem *PathItem) UnmarshalJSON(data []byte) error { } func (pathItem *PathItem) Operations() map[string]*Operation { - operations := make(map[string]*Operation, 4) + operations := make(map[string]*Operation) if v := pathItem.Connect; v != nil { operations[http.MethodConnect] = v } diff --git a/routers/legacy/router.go b/routers/legacy/router.go index 74e387323..911422b85 100644 --- a/routers/legacy/router.go +++ b/routers/legacy/router.go @@ -124,7 +124,7 @@ func (router *Router) FindRoute(req *http.Request) (*routers.Route, map[string]s Reason: routers.ErrPathNotFound.Error(), } } - pathParams = make(map[string]string, 8) + pathParams = make(map[string]string) paramNames, err := server.ParameterNames() if err != nil { return nil, nil, err