From 70c1649449128b439efa8ec256bd6d1deb1b2eac Mon Sep 17 00:00:00 2001 From: Eugene R Date: Sat, 16 Dec 2023 11:25:28 +0200 Subject: [PATCH] pre-allocate slice in flow.FanOut (#94) --- 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() {