Skip to content

Commit b5f844b

Browse files
committed
more pooling
Signed-off-by: Frederic BIDON <[email protected]>
1 parent d8542b1 commit b5f844b

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

info.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ func (v VendorExtensible) MarshalJSON() ([]byte, error) {
118118

119119
// UnmarshalJSON for this extensible object
120120
func (v *VendorExtensible) UnmarshalJSON(data []byte) error {
121-
var d map[string]interface{}
121+
d := poolOfMaps.BorrowMap()
122+
defer func() {
123+
poolOfMaps.RedeemMap(d)
124+
}()
122125
if err := json.Unmarshal(data, &d); err != nil {
123126
return err
124127
}

ref.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ func (r Ref) MarshalJSON() ([]byte, error) {
145145

146146
// UnmarshalJSON unmarshals this ref from a JSON object
147147
func (r *Ref) UnmarshalJSON(d []byte) error {
148-
var v map[string]interface{}
148+
v := poolOfMaps.BorrowMap()
149+
defer func() {
150+
poolOfMaps.RedeemMap(v)
151+
}()
149152
if err := json.Unmarshal(d, &v); err != nil {
150153
return err
151154
}
@@ -154,7 +157,7 @@ func (r *Ref) UnmarshalJSON(d []byte) error {
154157

155158
// GobEncode provides a safe gob encoder for Ref
156159
func (r Ref) GobEncode() ([]byte, error) {
157-
var b bytes.Buffer
160+
var b bytes.Buffer // TODO: grow
158161
raw, err := r.MarshalJSON()
159162
if err != nil {
160163
return nil, err
@@ -165,7 +168,7 @@ func (r Ref) GobEncode() ([]byte, error) {
165168

166169
// GobDecode provides a safe gob decoder for Ref
167170
func (r *Ref) GobDecode(b []byte) error {
168-
var raw []byte
171+
var raw []byte // TODO
169172
buf := bytes.NewBuffer(b)
170173
err := gob.NewDecoder(buf).Decode(&raw)
171174
if err != nil {

responses.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ type ResponsesProps struct {
9797

9898
// MarshalJSON marshals responses as JSON
9999
func (r ResponsesProps) MarshalJSON() ([]byte, error) {
100-
toser := map[string]Response{}
100+
toser := make(map[string]Response, len(r.StatusCodeResponses)+1)
101101
if r.Default != nil {
102102
toser["default"] = *r.Default
103103
}

schema.go

-1
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,6 @@ func (s *Schema) UnmarshalJSON(data []byte) error {
614614
SwaggerSchemaProps: props.SwaggerSchemaProps,
615615
}
616616

617-
//var d map[string]interface{}
618617
d := poolOfMaps.BorrowMap()
619618
defer func() {
620619
poolOfMaps.RedeemMap(d)

0 commit comments

Comments
 (0)