From 93f3568e941ba7539c07ec3b1989dcdf6cd3cc98 Mon Sep 17 00:00:00 2001 From: Jason Toffaletti Date: Wed, 23 Aug 2023 05:17:53 -0700 Subject: [PATCH] optimize Pipe.Wait (#187) use io.Copy with io.Discard instead of io.ReadAll to avoid allocating a buffer just to throw it away --- script.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.go b/script.go index 74111fa..213c8ce 100644 --- a/script.go +++ b/script.go @@ -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) }