pkg/pools: Use pool for strings.Builder everywhere

This commit is contained in:
Tom Wiesing 2023-01-24 10:52:15 +01:00
parent 8af2213d5a
commit a63bb2f669
No known key found for this signature in database
7 changed files with 44 additions and 25 deletions

View file

@ -7,8 +7,9 @@ import (
"math/rand"
"net/url"
"reflect"
"strings"
"time"
"github.com/FAU-CDI/wisski-distillery/pkg/pools"
)
// Config represents the configuration of a WissKI Distillery.
@ -111,7 +112,8 @@ func (config *Config) CSRFSecret() []byte {
// String serializes this configuration into a string
func (config Config) String() string {
values := &strings.Builder{}
builder := pools.GetBuilder()
defer pools.ReleaseBuilder(builder)
vConfig := reflect.ValueOf(config)
tConfig := vConfig.Type()
@ -127,8 +129,8 @@ func (config Config) String() string {
continue
}
fmt.Fprintf(values, "%s=%v\n", env, vField.Interface())
fmt.Fprintf(builder, "%s=%v\n", env, vField.Interface())
}
return values.String()
return builder.String()
}