Skip to content

Commit

Permalink
pre-allocate slice in flow.FanOut (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn authored Dec 16, 2023
1 parent 1049716 commit 70c1649
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 70c1649

Please sign in to comment.