From c797914429114fc6c29df9970d9d9b9b02563eb7 Mon Sep 17 00:00:00 2001 From: reugn <reugpro@gmail.com> Date: Sat, 16 Dec 2023 11:21:01 +0200 Subject: [PATCH] pre-allocate slice in flow.FanOut --- flow/util.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flow/util.go b/flow/util.go index e40343b..771d6e2 100644 --- a/flow/util.go +++ b/flow/util.go @@ -40,9 +40,9 @@ func Split[T any](outlet streams.Outlet, predicate func(T) bool) [2]streams.Flow // FanOut creates a number of identical flows from the single outlet. // This can be useful when writing to multiple sinks is required. func FanOut(outlet streams.Outlet, magnitude int) []streams.Flow { - var out []streams.Flow + out := make([]streams.Flow, magnitude) for i := 0; i < magnitude; i++ { - out = append(out, NewPassThrough()) + out[i] = NewPassThrough() } go func() {