Skip to content

Commit

Permalink
optimize Pipe.Wait (#187)
Browse files Browse the repository at this point in the history
use io.Copy with io.Discard instead of io.ReadAll to avoid allocating a buffer just to throw it away
  • Loading branch information
toffaletti authored Aug 23, 2023
1 parent b4160e2 commit 93f3568
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion script.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ func (p *Pipe) Tee(writers ...io.Writer) *Pipe {
// useful for waiting until concurrent filters have completed (see
// [Pipe.Filter]).
func (p *Pipe) Wait() {
_, err := io.ReadAll(p)
_, err := io.Copy(io.Discard, p)
if err != nil {
p.SetError(err)
}
Expand Down

0 comments on commit 93f3568

Please sign in to comment.