transform: Simplify the 0 transformer case

This commit is contained in:
Bjørn Erik Pedersen 2018-08-05 11:23:53 +02:00
parent 31faf98ce3
commit 27110133ff
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F

View file

@ -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)