putBuffer returns a buffer to the pool after use. The buffer is reset (cleared) before being returned to the pool. Nil buffers are safely ignored.
(buf *bytes.Buffer)
| 42 | // The buffer is reset (cleared) before being returned to the pool. |
| 43 | // Nil buffers are safely ignored. |
| 44 | func putBuffer(buf *bytes.Buffer) { |
| 45 | if buf != nil { |
| 46 | buf.Reset() |
| 47 | bufferPool.Put(buf) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // tokenizerPool provides object pooling for Tokenizer instances. |
| 52 | // This dramatically reduces allocations in high-throughput scenarios. |