Skip to content

proposal: x/text/transform: Add func (*Reader).Reset(r io.Reader, t Transformer) #55325

Open
@icholy

Description

@icholy

The x/test/transform.Reader constructor allocates two 4kb buffers. I want to reuse existing Readers with a sync.Pool to reduce allocations. I'm proposing a Reset method similar to bufio.Reader.Reset

func (rd *Reader) Reset(r io.Reader, t Transformer) {
	t.Reset()
	rd.r = r
	rd.t = t
	rd.err = nil
	rd.dst0 = 0
	rd.dst1 = 0
	rd.src0 = 0
	rd.src1 = 0
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions