Browse Source

pointless optimization

pull/2137/head
Shivaram Lingamneni 2 months ago
parent
commit
d1485d6345
3 changed files with 11 additions and 7 deletions
  1. 9
    5
      irc/channel.go
  2. 1
    1
      irc/client.go
  3. 1
    1
      irc/nickname.go

+ 9
- 5
irc/channel.go View File

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

+ 1
- 1
irc/client.go View File

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

+ 1
- 1
irc/nickname.go View File

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

Loading…
Cancel
Save