Skip to content

Conversation

@zhuzhu67373
Copy link

Bytes() and String() cannot be used when using fflib.Buffer in sync.Pool , like:

var bufPool = sync.Pool{
	New: func() interface{} {
		return fflib.NewBuffer([]byte{})
	},
}

func GetBuf() *fflib.Buffer {
	return bufPool.Get().(*fflib.Buffer)
}

func PutBuf(buf *fflib.Buffer) {
	buf.Reset()
	bufPool.Put(buf)
}

So I add copy version of Bytes() and String()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant