valyala / fasttemplate

Simple and fast template engine for Go
MIT License
846 stars 81 forks source link

Question: why a pool for each template? #1

Closed mathvav closed 8 years ago

mathvav commented 8 years ago

Why do you use a worker pool for bytes.Buffers that are template-specific (vs. a global pool)? Is it for getting similar sized buffers each time, or is there another reason?

valyala commented 8 years ago

It is for getting similar sized buffers each time. This reduces memory waste if multiple templates with different sizes are in concurrent use.