Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

buffer_pool.go 327B

123456789101112131415161718192021222324252627
  1. package wrappers
  2. import (
  3. "bytes"
  4. "sync"
  5. )
  6. var bufPool sync.Pool
  7. func getBuffer() *bytes.Buffer {
  8. buf := bufPool.Get().(*bytes.Buffer)
  9. buf.Reset()
  10. return buf
  11. }
  12. func putBuffer(buf *bytes.Buffer) {
  13. bufPool.Put(buf)
  14. }
  15. func init() {
  16. bufPool = sync.Pool{
  17. New: func() interface{} {
  18. return &bytes.Buffer{}
  19. },
  20. }
  21. }