Telnet: Preallocate pixel variable

This commit is contained in:
Alexandre Iooss 2020-10-14 16:10:04 +02:00
parent 1e712b2795
commit 868ee12726
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
1 changed files with 2 additions and 1 deletions

View File

@ -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"