Grow buffer each time

This commit is contained in:
Alexandre Iooss 2020-10-14 16:46:39 +02:00
parent 67ef07cac5
commit 36a890a914
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
1 changed files with 1 additions and 1 deletions

View File

@ -143,7 +143,6 @@ func StartASCIIArtStream(streamID string, reader io.ReadCloser) {
currentMessage[streamID] = new(string)
pixelBuff := make([]byte, Cfg.Width*Cfg.Height)
textBuff := strings.Builder{}
textBuff.Grow((2*Cfg.Width + 1) * Cfg.Height)
for {
n, err := reader.Read(pixelBuff)
if err != nil {
@ -157,6 +156,7 @@ func StartASCIIArtStream(streamID string, reader io.ReadCloser) {
// Header
textBuff.Reset()
textBuff.Grow((2*Cfg.Width + 1) * Cfg.Height)
for i := 0; i < 42; i++ {
textBuff.WriteByte('\n')
}