mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 17:32:25 -05:00 
			
		
		
		
	update dependencies (#296)
This commit is contained in:
		
					parent
					
						
							
								2aaec82732
							
						
					
				
			
			
				commit
				
					
						829a934d23
					
				
			
		
					 124 changed files with 2453 additions and 1588 deletions
				
			
		
							
								
								
									
										46
									
								
								vendor/codeberg.org/gruf/go-pools/bytes.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								vendor/codeberg.org/gruf/go-pools/bytes.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,46 @@ | |||
| package pools | ||||
| 
 | ||||
| import ( | ||||
| 	"sync" | ||||
| 
 | ||||
| 	"codeberg.org/gruf/go-bytes" | ||||
| ) | ||||
| 
 | ||||
| // BufferPool is a pooled allocator for bytes.Buffer objects | ||||
| type BufferPool interface { | ||||
| 	// Get fetches a bytes.Buffer from pool | ||||
| 	Get() *bytes.Buffer | ||||
| 
 | ||||
| 	// Put places supplied bytes.Buffer in pool | ||||
| 	Put(*bytes.Buffer) | ||||
| } | ||||
| 
 | ||||
| // NewBufferPool returns a newly instantiated bytes.Buffer pool | ||||
| func NewBufferPool(size int) BufferPool { | ||||
| 	return &bufferPool{ | ||||
| 		pool: sync.Pool{ | ||||
| 			New: func() interface{} { | ||||
| 				return &bytes.Buffer{B: make([]byte, 0, size)} | ||||
| 			}, | ||||
| 		}, | ||||
| 		size: size, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // bufferPool is our implementation of BufferPool | ||||
| type bufferPool struct { | ||||
| 	pool sync.Pool | ||||
| 	size int | ||||
| } | ||||
| 
 | ||||
| func (p *bufferPool) Get() *bytes.Buffer { | ||||
| 	return p.pool.Get().(*bytes.Buffer) | ||||
| } | ||||
| 
 | ||||
| func (p *bufferPool) Put(buf *bytes.Buffer) { | ||||
| 	if buf.Cap() < p.size { | ||||
| 		return | ||||
| 	} | ||||
| 	buf.Reset() | ||||
| 	p.pool.Put(buf) | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue