🚀 perf: CPU optimization

This commit is contained in:
2026-07-14 13:30:28 +07:00
parent dbf318a20e
commit d7e831f373
4 changed files with 170 additions and 43 deletions
+6 -1
View File
@@ -457,6 +457,7 @@ func (s *Server) playVideo(
currentFrame := 0
loopCount := 0
lastW, lastH := 0, 0
var writeBuf []byte
for {
select {
@@ -488,7 +489,11 @@ func (s *Server) playVideo(
prefix = clearScreen
lastW, lastH = w, h
}
if _, err := channel.Write([]byte(syncStart + prefix + ascii + syncEnd)); err != nil {
writeBuf = append(writeBuf[:0], syncStart...)
writeBuf = append(writeBuf, prefix...)
writeBuf = append(writeBuf, ascii...)
writeBuf = append(writeBuf, syncEnd...)
if _, err := channel.Write(writeBuf); err != nil {
closeSession()
return
}