From: Bjørn Erik Pedersen Date: Sun, 5 Aug 2018 09:23:53 +0000 (+0200) Subject: transform: Simplify the 0 transformer case X-Git-Tag: v0.47~43 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=27110133ffca05feae2e11a9ff28a9a00f613350;p=brevno-suite%2Fhugo transform: Simplify the 0 transformer case --- diff --git a/transform/chain.go b/transform/chain.go index f9c99a04..f71de94c 100644 --- a/transform/chain.go +++ b/transform/chain.go @@ -65,6 +65,10 @@ func (ft fromToBuffer) Content() []byte { } func (c *chain) Apply(w io.Writer, r io.Reader, p []byte) error { + if len(*c) == 0 { + _, err := io.Copy(w, r) + return err + } b1 := bp.GetBuffer() defer bp.PutBuffer(b1) @@ -73,11 +77,6 @@ func (c *chain) Apply(w io.Writer, r io.Reader, p []byte) error { return err } - if len(*c) == 0 { - _, err := b1.WriteTo(w) - return err - } - b2 := bp.GetBuffer() defer bp.PutBuffer(b2)