Grow buffer when encoding when necessary
Some checks failed
Run Tests / Test (push) Failing after 15s
Benchmark BufferPool / RunBenchmarks (push) Failing after 16s

To maybe hopefully prevent multiple allocations
This commit is contained in:
2024-07-30 23:34:50 +02:00
parent ee4f8ecfd6
commit f847588a24
2 changed files with 24 additions and 0 deletions

View File

@@ -19,6 +19,11 @@ func (c *GSM7Coder) Encode(s string, buf *bytes.Buffer) error {
bitshift byte = 0
leap, shift bool
)
encodedSize := GSM7EncodesInto(&s)
cap := buf.Cap()
if cap < encodedSize {
buf.Grow(encodedSize-cap)
}
for index, septet := range utf8 {
if septet > 0b01111111 {