mirror of
				https://github.com/traefik/traefik.git
				synced 2025-10-31 00:11:38 +01:00 
			
		
		
		
	Co-authored-by: Romain <rtribotte@users.noreply.github.com> Co-authored-by: Julien Salleyron <julien.salleyron@gmail.com>
		
			
				
	
	
		
			30 lines
		
	
	
		
			403 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			403 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package httputil
 | |
| 
 | |
| import "sync"
 | |
| 
 | |
| const bufferSize = 32 * 1024
 | |
| 
 | |
| type bufferPool struct {
 | |
| 	pool sync.Pool
 | |
| }
 | |
| 
 | |
| func newBufferPool() *bufferPool {
 | |
| 	b := &bufferPool{
 | |
| 		pool: sync.Pool{},
 | |
| 	}
 | |
| 
 | |
| 	b.pool.New = func() interface{} {
 | |
| 		return make([]byte, bufferSize)
 | |
| 	}
 | |
| 
 | |
| 	return b
 | |
| }
 | |
| 
 | |
| func (b *bufferPool) Get() []byte {
 | |
| 	return b.pool.Get().([]byte)
 | |
| }
 | |
| 
 | |
| func (b *bufferPool) Put(bytes []byte) {
 | |
| 	b.pool.Put(bytes)
 | |
| }
 |