mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-04 17:42:46 +00:00
add a +1 with field growth to try minimise allocation for log 'msg' field
This commit is contained in:
parent
c4461809ea
commit
26b6fe9b05
|
@ -413,8 +413,8 @@ func logf(ctx context.Context, depth int, lvl LEVEL, fields []kv.Field, s string
|
||||||
buf.B = append(buf.B, ' ')
|
buf.B = append(buf.B, ' ')
|
||||||
|
|
||||||
if ctx != nil && len(ctxhooks) > 0 {
|
if ctx != nil && len(ctxhooks) > 0 {
|
||||||
// Ensure fields have extra necessary space.
|
// Ensure fields have space for hooks (+1 for below).
|
||||||
fields = xslices.GrowJust(fields, len(ctxhooks))
|
fields = xslices.GrowJust(fields, len(ctxhooks)+1)
|
||||||
|
|
||||||
// Pass context through hooks.
|
// Pass context through hooks.
|
||||||
for _, hook := range ctxhooks {
|
for _, hook := range ctxhooks {
|
||||||
|
@ -423,7 +423,7 @@ func logf(ctx context.Context, depth int, lvl LEVEL, fields []kv.Field, s string
|
||||||
}
|
}
|
||||||
|
|
||||||
if s != "" {
|
if s != "" {
|
||||||
// Append message as final log field.
|
// Append message (if given) as final log field.
|
||||||
fields = xslices.AppendJust(fields, kv.Field{
|
fields = xslices.AppendJust(fields, kv.Field{
|
||||||
K: "msg", V: fmt.Sprintf(s, a...),
|
K: "msg", V: fmt.Sprintf(s, a...),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue