ergochat / ergo

A modern IRC server (daemon/ircd) written in Go.
https://ergo.chat/
MIT License
2.23k stars 178 forks source link

reduce websocket read allocations #2037

Closed slingamn closed 1 year ago

slingamn commented 1 year ago

https://github.com/ergochat/ergo/blob/4317016a09a2629603fb6198cbeddf6afa28c8ce/irc/ircconn.go#L131

ReadMessage() allocates a temporary buffer for each message; we could instead use NextReader() and copy the results into a persistent buffer. (The contract for (IRCConn).ReadLine() only requires the resulting bytes to be valid until the next call.)

slingamn commented 1 year ago

Done in #2038