Files
William Douglas 04ff3259ab Update how-to-make-a-release with detailed steps
And run them for a commit (needed to poke the go version in go.mod due
to a dependency update needing at least go 1.17).

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-22 11:28:50 -08:00

22 lines
520 B
Go

// Copyright 2015 Huan Du. All rights reserved.
// Licensed under the MIT license that can be found in the LICENSE file.
package xstrings
const bufferMaxInitGrowSize = 2048
// Lazy initialize a buffer.
func allocBuffer(orig, cur string) *stringBuilder {
output := &stringBuilder{}
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
}