Skip to content
Permalink
Browse files

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

  • Loading branch information...
DarthSim committed Oct 23, 2019
1 parent 4d36527 commit c91d10905728ec78e86875766cd2c53371391fbf
Showing with 8 additions and 1 deletion.
  1. +8 −1 struct-diff/diff.go
@@ -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()

0 comments on commit c91d109

Please sign in to comment.
You can’t perform that action at this time.