diff --git a/info.go b/info.go index b9f1a2b..19ea9c4 100644 --- a/info.go +++ b/info.go @@ -118,7 +118,10 @@ func (v VendorExtensible) MarshalJSON() ([]byte, error) { // UnmarshalJSON for this extensible object func (v *VendorExtensible) UnmarshalJSON(data []byte) error { - var d map[string]interface{} + d := poolOfMaps.BorrowMap() + defer func() { + poolOfMaps.RedeemMap(d) + }() if err := json.Unmarshal(data, &d); err != nil { return err } diff --git a/ref.go b/ref.go index eadf635..96fa345 100644 --- a/ref.go +++ b/ref.go @@ -145,7 +145,10 @@ func (r Ref) MarshalJSON() ([]byte, error) { // UnmarshalJSON unmarshals this ref from a JSON object func (r *Ref) UnmarshalJSON(d []byte) error { - var v map[string]interface{} + v := poolOfMaps.BorrowMap() + defer func() { + poolOfMaps.RedeemMap(v) + }() if err := json.Unmarshal(d, &v); err != nil { return err } @@ -154,7 +157,7 @@ func (r *Ref) UnmarshalJSON(d []byte) error { // GobEncode provides a safe gob encoder for Ref func (r Ref) GobEncode() ([]byte, error) { - var b bytes.Buffer + var b bytes.Buffer // TODO: grow raw, err := r.MarshalJSON() if err != nil { return nil, err @@ -165,7 +168,7 @@ func (r Ref) GobEncode() ([]byte, error) { // GobDecode provides a safe gob decoder for Ref func (r *Ref) GobDecode(b []byte) error { - var raw []byte + var raw []byte // TODO buf := bytes.NewBuffer(b) err := gob.NewDecoder(buf).Decode(&raw) if err != nil { diff --git a/responses.go b/responses.go index ecc5aec..8a67116 100644 --- a/responses.go +++ b/responses.go @@ -97,7 +97,7 @@ type ResponsesProps struct { // MarshalJSON marshals responses as JSON func (r ResponsesProps) MarshalJSON() ([]byte, error) { - toser := map[string]Response{} + toser := make(map[string]Response, len(r.StatusCodeResponses)+1) if r.Default != nil { toser["default"] = *r.Default } diff --git a/schema.go b/schema.go index 92e71c3..f845f7a 100644 --- a/schema.go +++ b/schema.go @@ -614,7 +614,6 @@ func (s *Schema) UnmarshalJSON(data []byte) error { SwaggerSchemaProps: props.SwaggerSchemaProps, } - //var d map[string]interface{} d := poolOfMaps.BorrowMap() defer func() { poolOfMaps.RedeemMap(d)