Make length check clearer in sendNames

This commit is contained in:
Simon Ser 2020-07-06 10:59:34 +02:00
parent 82990fb774
commit 4c8b01fb51
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -48,7 +48,8 @@ func sendNames(dc *downstreamConn, ch *upstreamChannel) {
for nick, memberships := range ch.Members { for nick, memberships := range ch.Members {
s := memberships.Format(dc) + dc.marshalEntity(ch.conn.network, nick) s := memberships.Format(dc) + dc.marshalEntity(ch.conn.network, nick)
if buf.Len() != 0 && maxLength < buf.Len()+1+len(s) { n := buf.Len() + 1 + len(s)
if buf.Len() != 0 && n > maxLength {
// There's not enough space for the next space + nick. // There's not enough space for the next space + nick.
dc.SendMessage(&irc.Message{ dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),