mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 00:11:04 +00:00 
			
		
		
		
	* Super expansion * Explain which features are in 1.11 vs 1.12 * Move imports Signed-off-by: jolheiser <john.olheiser@gmail.com>
		
			
				
	
	
		
			25 lines
		
	
	
	
		
			539 B
		
	
	
	
		
			Go
		
	
	
	
		
			Vendored
		
	
	
	
			
		
		
	
	
			25 lines
		
	
	
	
		
			539 B
		
	
	
	
		
			Go
		
	
	
	
		
			Vendored
		
	
	
	
// Copyright 2015 Huan Du. All rights reserved.
 | 
						|
// Licensed under the MIT license that can be found in the LICENSE file.
 | 
						|
 | 
						|
package xstrings
 | 
						|
 | 
						|
import (
 | 
						|
	"bytes"
 | 
						|
)
 | 
						|
 | 
						|
const bufferMaxInitGrowSize = 2048
 | 
						|
 | 
						|
// Lazy initialize a buffer.
 | 
						|
func allocBuffer(orig, cur string) *bytes.Buffer {
 | 
						|
	output := &bytes.Buffer{}
 | 
						|
	maxSize := len(orig) * 4
 | 
						|
 | 
						|
	// Avoid to reserve too much memory at once.
 | 
						|
	if maxSize > bufferMaxInitGrowSize {
 | 
						|
		maxSize = bufferMaxInitGrowSize
 | 
						|
	}
 | 
						|
 | 
						|
	output.Grow(maxSize)
 | 
						|
	output.WriteString(orig[:len(orig)-len(cur)])
 | 
						|
	return output
 | 
						|
}
 |