From 868ee12726ec5560596bec17f26709948f73e798 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 14 Oct 2020 16:10:04 +0200 Subject: [PATCH] Telnet: Preallocate pixel variable --- stream/telnet/telnet.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stream/telnet/telnet.go b/stream/telnet/telnet.go index d14024f..1452e78 100644 --- a/stream/telnet/telnet.go +++ b/stream/telnet/telnet.go @@ -143,6 +143,7 @@ func StartASCIIArtStream(streamID string, reader io.ReadCloser) { currentMessage[streamID] = new(string) buff := make([]byte, Cfg.Width*Cfg.Height) header := "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + var pixel byte for { n, _ := reader.Read(buff) if n == 0 { @@ -151,7 +152,7 @@ func StartASCIIArtStream(streamID string, reader io.ReadCloser) { imageStr := "" for j := 0; j < Cfg.Height; j++ { for i := 0; i < Cfg.Width; i++ { - pixel := buff[Cfg.Width*j+i] + pixel = buff[Cfg.Width*j+i] imageStr += asciiChar(pixel) + asciiChar(pixel) } imageStr += "\n"