Skip to content

Commit e6fb89c

Browse files
authored
Optimize allocation in AppendRecordAttrsToAttrs (#18)
1 parent 7caeb0b commit e6fb89c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

attributes.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import (
1717
type ReplaceAttrFn = func(groups []string, a slog.Attr) slog.Attr
1818

1919
func AppendRecordAttrsToAttrs(attrs []slog.Attr, groups []string, record *slog.Record) []slog.Attr {
20-
output := slices.Clone(attrs)
20+
output := make([]slog.Attr, 0, len(attrs)+record.NumAttrs())
21+
output = append(output, attrs...)
2122

2223
slices.Reverse(groups)
2324
record.Attrs(func(attr slog.Attr) bool {

0 commit comments

Comments
 (0)