pointless optimization

This commit is contained in:
Shivaram Lingamneni 2024-03-11 23:49:45 -04:00
parent 5a348fe6f5
commit d1485d6345
3 changed files with 11 additions and 7 deletions

View File

@ -1623,8 +1623,15 @@ func (channel *Channel) auditoriumFriends(client *Client) (friends []*Client) {
}
// returns whether the client is visible to unprivileged users in the channel
// (i.e., respecting auditorium mode)
func (channel *Channel) clientIsVisible(client *Client) bool {
// (i.e., respecting auditorium mode). note that this assumes that the client
// is a member; if the client is not, it may return true anyway
func (channel *Channel) memberIsVisible(client *Client) bool {
// fast path, we assume they're a member so if this isn't an auditorium,
// they're visible:
if !channel.flags.HasMode(modes.Auditorium) {
return true
}
channel.stateMutex.RLock()
defer channel.stateMutex.RUnlock()
@ -1632,9 +1639,6 @@ func (channel *Channel) clientIsVisible(client *Client) bool {
if !found {
return false
}
if !channel.flags.HasMode(modes.Auditorium) {
return true
}
return clientData.modes.HighestChannelUserMode() != modes.Mode(0)
}

View File

@ -1324,7 +1324,7 @@ func (client *Client) destroy(session *Session) {
friends := make(ClientSet)
channels := client.Channels()
for _, channel := range channels {
if channel.clientIsVisible(client) {
if channel.memberIsVisible(client) {
quitHistoryChannels = append(quitHistoryChannels, channel)
}
for _, member := range channel.auditoriumFriends(client) {

View File

@ -120,7 +120,7 @@ func performNickChange(server *Server, client *Client, target *Client, session *
}
for _, channel := range target.Channels() {
if channel.clientIsVisible(client) {
if channel.memberIsVisible(client) {
channel.AddHistoryItem(histItem, details.account)
}
}