Skip to content

Commit 14fd0ac

Browse files
authored
Remove unnecessary memory allocation (#11)
Creating a 0 length slice is less efficient than a nil slice pointer.
1 parent 804146f commit 14fd0ac

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

multi.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ func (h *FanoutHandler) Enabled(ctx context.Context, l slog.Level) bool {
3535

3636
// Implements slog.Handler
3737
func (h *FanoutHandler) Handle(ctx context.Context, r slog.Record) error {
38-
// We initialize this with a capacity of 0 to optimize for the path where there are no errors
39-
errs := make([]error, 0, 0)
38+
var errs []error
4039
for i := range h.handlers {
4140
if h.handlers[i].Enabled(ctx, r.Level) {
4241
err := try(func() error {

0 commit comments

Comments
 (0)