Skip to content

Commit

Permalink
pre-allocate slice in flow.FanOut
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn committed Dec 16, 2023
1 parent 1049716 commit c797914
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flow/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit c797914

Please sign in to comment.