Skip to content

Commit

Permalink
removed copying on slice creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Koss committed Jan 2, 2024
1 parent 8e252b1 commit eb6220d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions internal/internalpipe/constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ const (
)

func Slice[T any](dt []T) Pipe[T] {
dtCp := make([]T, len(dt))
copy(dtCp, dt)

return Pipe[T]{
Fn: func(i int) (*T, bool) {
if i >= len(dtCp) {
if i >= len(dt) {
return nil, true
}
return &dtCp[i], false
return &dt[i], false
},
Len: len(dtCp),
Len: len(dt),
ValLim: notSet,
GoroutinesCnt: defaultParallelWrks,
}
Expand Down

0 comments on commit eb6220d

Please sign in to comment.