1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-11-24 08:12:38 +02:00

Use strings.Builder in structdiff.Entries#String()

This commit is contained in:
DarthSim 2019-10-23 17:15:01 +06:00
parent 4d365273dc
commit c91d109057

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"reflect"
"strings"
"sync"
)
@ -14,6 +15,12 @@ var bufPool = sync.Pool{
},
}
var builderPool = sync.Pool{
New: func() interface{} {
return new(strings.Builder)
},
}
type Entry struct {
Name string
Value interface{}
@ -22,7 +29,7 @@ type Entry struct {
type Entries []Entry
func (d Entries) String() string {
buf := bufPool.Get().(*bytes.Buffer)
buf := builderPool.Get().(*strings.Builder)
last := len(d) - 1
buf.Reset()